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

# SDKs

> Use the official OpenAI and Anthropic SDKs with Antara.

Antara speaks the OpenAI and Anthropic wire formats, so their official SDKs work as they are. Set the API key and the base URL:

| SDK | Base URL | Endpoints |
| - | - | - |
| OpenAI (any language) | `https://api.antarah.dev/v1` | Chat Completions, Responses, Models |
| Anthropic (any language) | `https://api.antarah.dev` | Messages, count tokens. The SDK adds `/v1/messages` itself |

```python OpenAI · Python theme={null}
from openai import OpenAI

client = OpenAI(api_key="ak_...", base_url="https://api.antarah.dev/v1")

stream = client.chat.completions.create(
    model="a1",
    messages=[{"role": "user", "content": "Write a haiku about the desert."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")
```

```typescript OpenAI · TypeScript theme={null}
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "ak_...", baseURL: "https://api.antarah.dev/v1" });

const response = await client.responses.create({ model: "a1", input: "Write a haiku about the desert." });
console.log(response.output_text);
```

```python Anthropic · Python theme={null}
from anthropic import Anthropic

client = Anthropic(api_key="ak_...", base_url="https://api.antarah.dev")

with client.messages.stream(
    model="a1",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Write a haiku about the desert."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="")
```

```typescript Anthropic · TypeScript theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ apiKey: "ak_...", baseURL: "https://api.antarah.dev" });

const message = await client.messages.create({
  model: "a1",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Write a haiku about the desert." }],
});
const text = message.content.find((b) => b.type === "text");
console.log(text?.type === "text" ? text.text : "");
```

Other tools that let you set an OpenAI- or Anthropic-compatible base URL work the same way.

## What the SDKs get from Antara

| Behavior | Detail |
| - | - |
| Error classes | Inference errors use each API's native error shape, so `openai.RateLimitError`, `anthropic.AuthenticationError`, and the rest are raised as usual. See [Errors](https://docs.antarah.dev/guides/errors.md) |
| Retries | Every error response carries `x-should-retry: true` or `false`, which both SDKs follow. Only `429`, `409 idempotency_in_progress`, and retryable `5xx` errors say `true` |
| Request IDs | Every response has `x-request-id` and `request-id` (the same `req_…` value). Include it when you contact support |
| Rate-limit headers | `x-ratelimit-*` headers in OpenAI's format, plus IETF `RateLimit` headers. See [Rate limits](https://docs.antarah.dev/guides/rate-limits.md) |

## Fields that differ

Antara accepts each API's official request schema. A few fields are handled differently; the API reference lists all of them per endpoint.

| Endpoint | Not supported (`400 unsupported_parameter`) |
| - | - |
| Chat Completions | `n` other than 1, `audio`, `modalities` other than `["text"]`, `prediction`, `web_search_options`, `functions`, `function_call` |
| Responses | `previous_response_id`, `conversation`, `background: true`, built-in tools (`web_search`, `web_search_preview`, `file_search`, `code_interpreter`, `computer_use_preview`, `image_generation`, `mcp`, `local_shell`). Responses is stateless: `store` is always `false` |
| Messages | `top_k`, server tools (web search, web fetch, code execution), `document` / PDF blocks, `container`, `mcp_servers` |

Fields Antara accepts but doesn't forward, so SDK defaults never break a request: `user`, `safety_identifier`, `store`, `metadata`, `service_tier` (Chat Completions and Responses), and `metadata`, `service_tier`, `cache_control`, `anthropic-beta` (Messages). Prompt caching is automatic.

> [!WARNING]
>
> `/v1/responses` works only for models whose runtime serves the Responses API; others answer `400 unsupported_parameter` with `param: "model"`. Chat Completions and Messages work for every model.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.