Skip to main content

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.
1

Get your API key

Sign up for a Concentrate AI account and create an API key from your dashboard.
  1. Visit concentrate.ai
  2. Sign up or log in
  3. Navigate to API Keys
  4. Click Create API Key
  5. Copy your key (it starts with sk-cn)
Keep your API key secure. Never commit it to version control or share it publicly.
2

Optional: configure guardrails

Guardrails are API-key-level redaction settings.
  1. Go to Guardrails in the dashboard
  2. Select your API key
  3. Enable redaction and choose target (input, output, or both)
  4. 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.
3

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
  }
}
4

Usage in practice

Below are examples of usage in a variety of different programming languages:
Install the requests library:
pip install requests
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:
python test.py

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
  }'

Try Tool Calling

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
}
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