> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# With Adaline Proxy

> Instrument your AI application with zero code changes by routing requests through the Adaline Proxy

Proxy is a hosted proxy service that automatically captures telemetry, traces, and spans from your AI applications.

Instead of calling AI provider APIs directly, your applications route requests through Adaline's cloud infrastructure by simply modifying the `baseUrl` in your AI SDKs and adding required headers. This enables automatic observability without manual instrumentation.

Proxy is based on the open source [Adaline Gateway](https://github.com/adaline/gateway) project.

<img src="https://mintcdn.com/adaline/Um_T8BffW4hfcoYD/images/instrument/proxy-flow.svg?fit=max&auto=format&n=Um_T8BffW4hfcoYD&q=85&s=a965d276196cb987b5b4a0e7cdc45b43" alt="Proxy flow diagram" width="740" height="270" data-path="images/instrument/proxy-flow.svg" />

### The flow

1. **SDK Configuration** — Update your AI SDK's `baseUrl` to point to Proxy
2. **Header Addition** — Add required Adaline headers for authentication, project and prompt identification
3. **Transparent Proxying** — Proxy forwards your requests to the actual AI provider
4. **Automatic Telemetry** — Responses are captured and logged as traces and spans in your Adaline project and prompt
5. **Original Response** — Your application receives the exact same response it would from the provider

## Benefits

* **Minimal Code Changes** — Works with existing AI SDK implementations by adding a couple of lines of code
* **Automatic Observability** — Captures traces and spans without manual logging
* **Real-time Monitoring** — Immediate visibility into AI application performance, including token usage and costs
* **Continuous Evaluations** — Setup one-click [continuous AI evaluations](/docs/monitor/setup-continuous-evaluations) for your AI applications
* **Provider Agnostic** — Supports all major AI providers
* **Production Ready** — Built for scale with high availability and security
* **No Extra Costs** — Proxy requests are billed as regular API Log requests to Adaline

## Quick start

<Tabs>
  <Tab title="Python (OpenAI)">
    ```python theme={null}
    import os
    from openai import OpenAI

    client = OpenAI(
        api_key=os.getenv("OPENAI_API_KEY"),
        base_url="https://gateway.adaline.ai/v1/openai/",
    )

    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}],
        extra_headers={
            "adaline-api-key": os.getenv("ADALINE_API_KEY"),
            "adaline-project-id": os.getenv("ADALINE_PROJECT_ID"),
            "adaline-prompt-id": os.getenv("ADALINE_PROMPT_ID"),
            "adaline-trace-name": "my-workflow",
        },
    )
    ```
  </Tab>

  <Tab title="TypeScript (OpenAI)">
    ```typescript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      apiKey: process.env.OPENAI_API_KEY,
      baseURL: "https://gateway.adaline.ai/v1/openai/",
      defaultHeaders: {
        "adaline-api-key": process.env.ADALINE_API_KEY,
        "adaline-project-id": process.env.ADALINE_PROJECT_ID,
        "adaline-prompt-id": process.env.ADALINE_PROMPT_ID,
      },
    });

    const response = await client.chat.completions.create({
      model: "gpt-4",
      messages: [{ role: "user", content: "Hello!" }],
    });
    ```
  </Tab>

  <Tab title="Python (Anthropic)">
    ```python theme={null}
    import os
    from anthropic import Anthropic

    client = Anthropic(
        api_key=os.getenv("ANTHROPIC_API_KEY"),
        base_url="https://gateway.adaline.ai/v1/anthropic/",
        default_headers={
            "adaline-api-key": os.getenv("ADALINE_API_KEY"),
            "adaline-project-id": os.getenv("ADALINE_PROJECT_ID"),
            "adaline-prompt-id": os.getenv("ADALINE_PROMPT_ID"),
        },
    )

    response = client.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=1024,
        messages=[{"role": "user", "content": "Hello!"}],
    )
    ```
  </Tab>
</Tabs>

## Supported providers

| Provider       | Base URL                                     |
| -------------- | -------------------------------------------- |
| OpenAI         | `https://gateway.adaline.ai/v1/openai/`      |
| Anthropic      | `https://gateway.adaline.ai/v1/anthropic/`   |
| Google         | `https://gateway.adaline.ai/v1/google`       |
| Azure          | `https://gateway.adaline.ai/v1/azure/`       |
| Amazon Bedrock | `https://gateway.adaline.ai/v1/bedrock/`     |
| Groq           | `https://gateway.adaline.ai/v1/groq/`        |
| Open Router    | `https://gateway.adaline.ai/v1/open-router/` |
| Together AI    | `https://gateway.adaline.ai/v1/together-ai/` |
| xAI            | `https://gateway.adaline.ai/v1/xai/`         |
| Vertex AI      | `https://gateway.adaline.ai/v1/vertex`       |

## Required headers

| Header               | Description                        |
| -------------------- | ---------------------------------- |
| `adaline-api-key`    | Your workspace API key             |
| `adaline-project-id` | The project to log traces to       |
| `adaline-prompt-id`  | The prompt to associate spans with |

## Optional trace headers

| Header                       | Description                                              | Default        |
| ---------------------------- | -------------------------------------------------------- | -------------- |
| `adaline-trace-name`         | Name for the trace                                       | `"Proxy"`      |
| `adaline-trace-status`       | Trace status: `success`, `failure`, `pending`, `unknown` | Auto-detected  |
| `adaline-trace-reference-id` | Custom ID to group multiple requests into one trace      | Auto-generated |
| `adaline-trace-session-id`   | Session ID to group related traces                       | —              |
| `adaline-trace-attributes`   | JSON array of attribute operations                       | —              |
| `adaline-trace-tags`         | JSON array of tag operations                             | —              |

## Optional span headers

| Header                        | Description                                                                                |
| ----------------------------- | ------------------------------------------------------------------------------------------ |
| `adaline-span-name`           | Name for the span                                                                          |
| `adaline-span-reference-id`   | Custom span ID                                                                             |
| `adaline-span-session-id`     | Session ID on the span                                                                     |
| `adaline-span-variables`      | JSON object of variable values for evaluation                                              |
| `adaline-span-attributes`     | Custom span attributes                                                                     |
| `adaline-span-tags`           | Span tags                                                                                  |
| `adaline-span-run-evaluation` | Set to `"true"` to trigger [continuous evaluations](/docs/monitor/setup-continuous-evaluations) |
| `adaline-deployment-id`       | Deployment ID to associate with the span                                                   |

<Note>
  For the full header specification with validation rules and detailed examples, see the [Proxy Headers Reference](/docs/reference/proxy/headers).
</Note>

## Group requests into a single trace

Use the same `adaline-trace-reference-id` across multiple requests to group them under one trace:

```python theme={null}
import uuid

trace_id = str(uuid.uuid4())

# First request
embedding = client.embeddings.create(
    model="text-embedding-3-small",
    input="User query",
    extra_headers={
        "adaline-api-key": os.getenv("ADALINE_API_KEY"),
        "adaline-project-id": os.getenv("ADALINE_PROJECT_ID"),
        "adaline-prompt-id": os.getenv("ADALINE_PROMPT_ID"),
        "adaline-trace-reference-id": trace_id,
        "adaline-span-name": "query-embedding",
    },
)

# Second request — same trace
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "..."}],
    extra_headers={
        "adaline-api-key": os.getenv("ADALINE_API_KEY"),
        "adaline-project-id": os.getenv("ADALINE_PROJECT_ID"),
        "adaline-prompt-id": os.getenv("ADALINE_PROMPT_ID"),
        "adaline-trace-reference-id": trace_id,
        "adaline-span-name": "chat-completion",
    },
)
```

## What gets captured automatically

When you route through the Proxy, Adaline automatically captures:

* Request and response payloads
* Token usage (input and output) and cost
* Latency
* Model and provider information
* Errors and status codes

## Next steps

<CardGroup cols={2}>
  <Card title="Proxy Headers Reference" icon="list" href="/docs/reference/proxy/headers">
    Complete reference for all required and optional Proxy headers.
  </Card>

  <Card title="Advanced Usage" icon="git-branch" href="/docs/instrument/advanced-usage">
    Session tracking, multi-step traces, and error patterns.
  </Card>

  <Card title="Setup Continuous Evaluations" icon="chart-line" href="/docs/monitor/setup-continuous-evaluations">
    Run automated quality checks on live production data.
  </Card>

  <Card title="Log Attachments" icon="paperclip" href="/docs/instrument/log-attachments">
    Attach custom attributes, tags, and variables.
  </Card>

  <Card title="Integrations" icon="plug" href="/docs/integrations/introduction">
    Browse all supported AI providers and frameworks.
  </Card>

  <Card title="Adaline Gateway (Open Source)" icon="github" href="https://github.com/adaline/gateway">
    The open source project that powers Proxy.
  </Card>
</CardGroup>
