# Native provider routes

> Use each provider's own API and SDK through ACOG, byte for byte: Anthropic, OpenAI, Vertex AI, Bedrock, Azure OpenAI and custom endpoints.

Product: AI Cost Optimizer Gateway (ACOG). Web version: https://tessarac.com/docs/acog/api/native-routes. Last updated: 2026-10-16.

The compatible endpoints translate between API shapes. The native routes do not: each forwards your request to one provider in that provider's own format, with your connection's credentials in place of the gateway key. Use them when you need a provider feature the compatible endpoints do not cover (token counting, Message Batches, the OpenAI Responses API, Bedrock's Converse API), or to keep existing provider-SDK code unchanged apart from its base URL.

## Routes

| Route | Forwards to | Base URL for the provider's SDK |
|---|---|---|
| `/anthropic/…` | Your Direct Anthropic connection | `https://gateway.acog.tessarac.com/anthropic` |
| `/openai/…` | Your Direct OpenAI connection | `https://gateway.acog.tessarac.com/openai/v1` |
| `/vertex/…` | Your Vertex AI connection for the model in the path | `https://gateway.acog.tessarac.com/vertex` |
| `/bedrock/…` | Your Bedrock connection | `https://gateway.acog.tessarac.com/bedrock` |
| `/azure/…` | Your Azure OpenAI connection | `https://gateway.acog.tessarac.com/azure` |
| `/custom/…` | Your custom connection | `https://gateway.acog.tessarac.com/custom` |

The path after the prefix is the provider's own path. A request to a route with no matching connection is refused with `409 connection_not_configured`.

## Authentication

Each route reads the gateway key from the header that provider's SDK already sends, so you only swap the key:

| Route | Header |
|---|---|
| `/anthropic` | `x-api-key: acog_…` (a bearer token is not read on this route) |
| `/openai`, `/vertex`, `/custom` | `Authorization: Bearer acog_…` |
| `/azure` | `api-key: acog_…` |
| `/bedrock` | An AWS Signature Version 4 signature made with an issued ACOG Bedrock credential. See [AWS Bedrock](https://tessarac.com/docs/acog/providers/aws-bedrock.md#native-bedrock-access-with-boto3). |

Every route also accepts `x-acog-key: acog_…`.

## Examples

**Anthropic SDK, including token counting and Message Batches**

```python
import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://gateway.acog.tessarac.com/anthropic",
    api_key=os.environ["ACOG_API_KEY"],  # sent as x-api-key, which this route reads
)

count = client.messages.count_tokens(
    model="claude-haiku-4-5",
    messages=[{"role": "user", "content": "Hello"}],
)

batch = client.messages.batches.create(
    requests=[{
        "custom_id": "first",
        "params": {"model": "claude-haiku-4-5", "max_tokens": 64,
                   "messages": [{"role": "user", "content": "Hello"}]},
    }]
)
```

**OpenAI SDK, Responses API**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://gateway.acog.tessarac.com/openai/v1", api_key=os.environ["ACOG_API_KEY"])
response = client.responses.create(model="gpt-4.1-mini", input="Hello")
```

**Vertex AI, Gemini `generateContent`**

```bash
curl -s "https://gateway.acog.tessarac.com/vertex/v1/projects/my-project/locations/us-central1/publishers/google/models/gemini-3.1-flash-lite:generateContent" \
  -H "Authorization: Bearer $ACOG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]}'
```

**Azure OpenAI SDK**

```python
import os
from openai import AzureOpenAI

client = AzureOpenAI(
    base_url="https://gateway.acog.tessarac.com/azure/openai",
    api_key=os.environ["ACOG_API_KEY"],
    api_version="2024-10-21",
)
completion = client.chat.completions.create(
    model="gpt-4o-mini",  # the deployment name
    messages=[{"role": "user", "content": "Hello"}],
)
```

## What ACOG does on a native route

| | Native routes |
|---|---|
| Request body | Forwarded as sent, including provider-only fields. Only provider prompt-cache markers, [prompt cleanup](https://tessarac.com/docs/acog/optimize/request-cleanup.md) and data loss prevention masking can change it. |
| Provider headers (`anthropic-version`, `anthropic-beta`, your own tracing headers) | Forwarded |
| Your gateway key and any provider credential you sent | Removed; the connection's credentials are used |
| Response | Returned as the provider sent it, including errors |
| Model access rules, budgets, rate limits | Applied |
| Data loss prevention and prompt injection screening | Applied to request bodies ACOG can read |
| Response cache | Identical non-streaming requests are answered from cache |
| Provider prompt caching | Added on Direct Anthropic and OpenAI requests |
| Translation, auto mode, failover, `x-acog-batch` | Not available. Use the compatible endpoints for these. |
| `x-acog-resolved-model` header | Not set; the provider's response names the model |

### Model access on native routes

ACOG needs to know the model to apply model access rules. When a rule restricts models and ACOG cannot tell the model from the request (an opaque or multipart body), the request is refused with `403 model_unverifiable`.

### Vertex AI locations

A native Vertex request goes to the location configured for its model on your connection (its model region, or the connection's region), whatever location the URL names. It is not retried in other locations. See [Google Vertex AI](https://tessarac.com/docs/acog/providers/google-vertex-ai.md#region-where-requests-are-processed).
