Documentation Index
Fetch the complete documentation index at: https://concentrate.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Get Started
This quickstart guide will help you make your first request to the Concentrate AI API. You’ll be generating AI responses in minutes.
Get your API key
Sign up for a Concentrate AI account and create an API key from your dashboard.
- Visit concentrate.ai
- Sign up or log in
- Navigate to API Keys
- Click Create API Key
- Copy your key (it starts with sk-cn)
Keep your API key secure. Never commit it to version control or share it publicly.
Optional: configure guardrails
Guardrails are API-key-level redaction settings.
- Go to Guardrails in the dashboard
- Select your API key
- Enable redaction and choose target (
input, output, or both)
- Select entity types and save
Output redaction is applied to non-streamed responses. Streamed output ("stream": true) is not redacted.
See Guardrails & Redaction for details. Make your first request
Try the API with a simple cURL request:curl https://api.concentrate.ai/v1/responses \
-H "Content-Type: application/json" \
-H 'accept: application/json' \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.2",
"input": "What is the capital of France?"
}'
You should receive a response like this:{
"id": "abcd1234-ab12-cd34-ef56-abcdef12356",
"object": "response",
"created_at": 1702934400,
"status": "completed",
"error": null,
"incomplete_details": null,
"instructions": null,
"reasoning": {
"effort": null,
"summary": null
},
"model": "openai/gpt-5.2",
"output": [
{
"type": "message",
"role": "assistant",
"id": "abcd1234-ab12-cd34-ef56-abcdef12356",
"status": "completed",
"content": [
{
"type": "output_text",
"text": "The capital of France is Paris."
}
]
}
],
"tools": [],
"usage": {
"input_tokens": 8,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 8,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 16
}
}
Usage in practice
Below are examples of usage in a variety of different programming languages:Install the requests library:Create a file called test.py:import requests
response = requests.post(
"https://api.concentrate.ai/v1/responses",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "gpt-5.2",
"input": "Explain quantum computing in simple terms"
}
)
data = response.json()
print(data["output"][0]["content"][0]["text"])
Run it: Create a file called test.ts:interface ResponseRequest {
model: string;
input: string;
}
async function makeRequest() {
const response = await fetch("https://api.concentrate.ai/v1/responses", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "gpt-5.2",
input: "Explain quantum computing in simple terms"
} as ResponseRequest)
});
const data = await response.json();
console.log(data.output[0].content[0].text);
}
makeRequest();
Run it: Create a file called test.go:package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
reqBody := map[string]interface{}{
"model": "gpt-5.2",
"input": "Explain quantum computing in simple terms",
}
jsonData, _ := json.Marshal(reqBody)
req, _ := http.NewRequest("POST",
"https://api.concentrate.ai/v1/responses",
bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var result map[string]interface{}
json.Unmarshal(body, &result)
output := result["output"].([]interface{})[0].(map[string]interface{})
content := output["content"].([]interface{})[0].(map[string]interface{})
fmt.Println(content["text"])
}
Run it:
Try Different Models
Concentrate AI supports 50+ models. Try different ones to compare:
curl https://api.concentrate.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-5",
"input": "Write a haiku about programming"
}'
Try Streaming
Enable real-time streaming for a better user experience:
curl https://api.concentrate.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.2",
"input": "Write a short story about a robot",
"stream": true
}'
Enable your AI to call functions and use external tools:
curl https://api.concentrate.ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5.2",
"input": "What is 25 * 17?",
"tools": [
{
"type": "function",
"name": "calculate",
"description": "Perform mathematical calculations",
"parameters": {
"type": "object",
"properties": {
"expression": {"type": "string"}
},
"required": ["expression"]
}
}
]
}'
The model will respond with a function_call indicating it wants to use the tool. See the Tool Calling Guide for the complete multi-turn workflow.
Common Patterns
Multi-Turn Conversation
input = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is Python?"},
{"role": "assistant", "content": "Python is a high-level programming language."},
{"role": "user", "content": "What is it used for?"}
]
response = requests.post(
"https://api.concentrate.ai/v1/responses",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "gpt-5.2",
"input": input
}
)
Control Parameters
response = requests.post(
"https://api.concentrate.ai/v1/responses",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "gpt-5.2",
"input": "Write a creative story",
"temperature": 1.5, # More creative
"max_output_tokens": 500, # Limit length
"top_p": 0.95 # Nucleus sampling
}
)
Error Handling
try:
response = requests.post(
"https://api.concentrate.ai/v1/responses",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "gpt-5.2",
"input": "Hello"
}
)
if response.status_code == 200:
data = response.json()
print(data["output"][0]["content"][0]["text"])
elif response.status_code == 402:
print("Insufficient credits - please add funds")
elif response.status_code == 424:
print("Provider error - try a different provider")
# Retry with alternative provider/model
else:
print(f"Error: {response.status_code}")
print(response.json())
except Exception as e:
print(f"Request failed: {e}")
Next Steps
Now that you’ve made your first request, explore more features:
API Reference
Complete API documentation
Streaming Responses
Real-time streaming guide
Auto Routing
Automatic model selection
Error Handling
Handle errors gracefully
Best Practices
Always set max_output_tokens to prevent unexpectedly long responses:{
"model": "gpt-5.2",
"input": "Your prompt",
"max_output_tokens": 500
}
Use environment variables
Never hardcode API keys. Use environment variables:import os
api_key = os.environ.get("CONCENTRATE_API_KEY")
Handle transient errors with exponential backoff:import time
for attempt in range(3):
try:
response = make_request()
break
except Exception as e:
if attempt < 2:
time.sleep(2 ** attempt)
Track token usage to manage costs:response = requests.post(
.....
)
data = response.json()
usage = data["usage"]
print(f"Tokens used: {usage['total_tokens']}")
Need Help?
View Examples
See more code examples
Contact Support
Get help from our team