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

# Quickstart

> Make your first API call in under 5 minutes

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

<Steps>
  <Step title="Get your API key">
    Sign up for a Concentrate AI account and create an API key from your dashboard.

    1. Visit [concentrate.ai](https://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)

    <Warning>
      Keep your API key secure. Never commit it to version control or share it publicly.
    </Warning>
  </Step>

  <Step title="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

    <Info>
      Output redaction is applied to non-streamed responses. Streamed output (`"stream": true`) is not redacted.
    </Info>

    See [Guardrails & Redaction](/docs/api-reference/endpoint/guardrails-redaction) for details.
  </Step>

  <Step title="Make your first request">
    Try the API with a simple cURL request:

    ```bash theme={null}
    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:

    ```json theme={null}
    {
      "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
      }
    }
    ```
  </Step>

  <Step title="Usage in practice">
    Below are examples of usage in a variety of different programming languages:

    <Tabs>
      <Tab title="Python">
        Install the requests library:

        ```bash theme={null}
        pip install requests
        ```

        Create a file called `test.py`:

        ```python theme={null}
        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:

        ```bash theme={null}
        python test.py
        ```
      </Tab>

      <Tab title="TypeScript">
        Create a file called `test.ts`:

        ```typescript theme={null}
        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:

        ```bash theme={null}
        ts-node test.ts
        ```
      </Tab>

      <Tab title="Go">
        Create a file called `test.go`:

        ```go theme={null}
        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:

        ```bash theme={null}
        go run test.go
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Try Different Models

Concentrate AI supports 50+ models. Try different ones to compare:

<CodeGroup>
  ```bash Claude Opus 4.5 theme={null}
  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"
    }'
  ```

  ```bash Gemini 2.5 Pro theme={null}
  curl https://api.concentrate.ai/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gemini-2.5-pro",
      "input": "Explain the theory of relativity"
    }'
  ```

  ```bash Auto Routing (Cheapest) theme={null}
  curl https://api.concentrate.ai/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "auto",
      "input": "Summarize this text",
      "routing": {
        "provider": { "sort": "cost" }
      }
    }'
  ```
</CodeGroup>

## Try Streaming

Enable real-time streaming for a better user experience:

<CodeGroup>
  ```bash cURL with Streaming theme={null}
  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
    }'
  ```

  ```python Python with Streaming theme={null}
  import requests
  import json

  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": "Write a short story about a robot",
          "stream": True
      },
      stream=True
  )

  for line in response.iter_lines():
      if line and line.startswith(b'data: '):
          data = json.loads(line[6:])
          if data.get("type") == "response.output_text.delta":
              print(data["delta"], end="", flush=True)
  ```
</CodeGroup>

## Try Tool Calling

Enable your AI to call functions and use external tools:

<CodeGroup>
  ```bash cURL theme={null}
  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"]
          }
        }
      ]
    }'
  ```

  ```python Python theme={null}
  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": "What is 25 * 17?",
          "tools": [
              {
                  "type": "function",
                  "name": "calculate",
                  "description": "Perform mathematical calculations",
                  "parameters": {
                      "type": "object",
                      "properties": {
                          "expression": {"type": "string"}
                      },
                      "required": ["expression"]
                  }
              }
          ]
      }
  )

  data = response.json()
  # Model will respond with a function_call
  for item in data["output"]:
      if item["type"] == "function_call":
          print(f"Tool: {item['name']}")
          print(f"Args: {item['arguments']}")
  ```
</CodeGroup>

The model will respond with a `function_call` indicating it wants to use the tool. See the [Tool Calling Guide](/docs/api-reference/endpoint/tool-calling) for the complete multi-turn workflow.

## Common Patterns

### Multi-Turn Conversation

```python theme={null}
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

```python theme={null}
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

```python theme={null}
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:

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" href="/docs/api-reference/introduction">
    Complete API documentation
  </Card>

  <Card title="Streaming Responses" icon="water" href="/docs/api-reference/endpoint/streaming">
    Real-time streaming guide
  </Card>

  <Card title="Auto Routing" icon="route" href="/docs/api-reference/endpoint/auto-routing">
    Automatic model selection
  </Card>

  <Card title="Error Handling" icon="triangle-exclamation" href="/docs/api-reference/endpoint/errors">
    Handle errors gracefully
  </Card>
</CardGroup>

## Best Practices

<AccordionGroup>
  <Accordion title="Set token limits" icon="gauge">
    Always set `max_output_tokens` to prevent unexpectedly long responses:

    ```json theme={null}
    {
      "model": "gpt-5.2",
      "input": "Your prompt",
      "max_output_tokens": 500
    }
    ```
  </Accordion>

  <Accordion title="Use environment variables" icon="key">
    Never hardcode API keys. Use environment variables:

    ```python theme={null}
    import os

    api_key = os.environ.get("CONCENTRATE_API_KEY")
    ```
  </Accordion>

  <Accordion title="Implement retry logic" icon="arrows-rotate">
    Handle transient errors with exponential backoff:

    ```python theme={null}
    import time

    for attempt in range(3):
        try:
            response = make_request()
            break
        except Exception as e:
            if attempt < 2:
                time.sleep(2 ** attempt)
    ```
  </Accordion>

  <Accordion title="Monitor usage" icon="chart-line">
    Track token usage to manage costs:

    ```python theme={null}
    response = requests.post(
      .....
    )
    data = response.json()
    usage = data["usage"]
    print(f"Tokens used: {usage['total_tokens']}")
    ```
  </Accordion>
</AccordionGroup>

## Need Help?

<CardGroup cols={2}>
  <Card title="View Examples" icon="code" href="/docs/api-reference/endpoint/create-response">
    See more code examples
  </Card>

  <Card title="Contact Support" icon="life-ring" href="mailto:support@concentrate.ai">
    Get help from our team
  </Card>
</CardGroup>
