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

# SDKs and integrations

> Point the OpenAI Python and Node SDKs, Vercel AI SDK, LangChain, the Anthropic SDK or Claude Code at the gateway by changing the base URL and the key.

The gateway speaks the OpenAI Chat Completions and Responses wire formats, so any
OpenAI-compatible client works by changing two things:

1. **Base URL** → `https://api.impossibl.com/v1`
2. **API key** → your gateway key (`imp-rt-...`, from `POST /v1/accounts`)

Then pick a `provider/model` id (e.g. `anthropic/claude-sonnet-4-5`). Everything
else in your code stays the same.

## OpenAI Python SDK

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

client = OpenAI(
    base_url="https://api.impossibl.com/v1",
    api_key="imp-rt-...",
)

resp = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

## OpenAI Node SDK

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

const client = new OpenAI({
  baseURL: "https://api.impossibl.com/v1",
  apiKey: "imp-rt-...",
});

const resp = await client.chat.completions.create({
  model: "google/gemini-2.5-flash",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
```

## Vercel AI SDK

Point the OpenAI provider at the gateway with `createOpenAI`:

```typescript theme={null}
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const gateway = createOpenAI({
  baseURL: "https://api.impossibl.com/v1",
  apiKey: "imp-rt-...",
});

const { text } = await generateText({
  model: gateway("openai/gpt-4o-mini"),
  prompt: "Hello!",
});
```

## LangChain (Python)

```python theme={null}
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="https://api.impossibl.com/v1",
    api_key="imp-rt-...",
    model="anthropic/claude-haiku-4-5",
)
print(llm.invoke("Hello!").content)
```

## Anthropic SDK

The gateway also implements Anthropic's Messages API at `POST /v1/messages`, so
the official `anthropic` SDK works as a drop-in too. The Anthropic SDK sends the
key as `x-api-key` and appends `/v1/messages` itself, so point its **base URL at
the gateway root** (no `/v1`):

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

client = Anthropic(
    base_url="https://api.impossibl.com",
    api_key="imp-rt-...",
)

msg = client.messages.create(
    model="claude-haiku-4-5",        # bare Anthropic id routes to Anthropic
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(msg.content[0].text)
```

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

const client = new Anthropic({
  baseURL: "https://api.impossibl.com",
  apiKey: "imp-rt-...",
});

const msg = await client.messages.create({
  model: "claude-haiku-4-5",
  max_tokens: 256,
  messages: [{ role: "user", content: "Hello!" }],
});
```

A bare `claude-...` id routes to Anthropic; use a `provider/model` id (e.g.
`openai/gpt-4o-mini`) to reach another provider through the Messages endpoint.

## Claude Code CLI

Point Anthropic's own [Claude Code](https://claude.com/claude-code) CLI at the gateway
with a few environment variables — this lets you run Claude Code against any model the
gateway serves (not just Claude), and BYOK credentials apply the same as any other
request:

```bash theme={null}
export ANTHROPIC_BASE_URL="https://api.impossibl.com"
export ANTHROPIC_AUTH_TOKEN="imp-rt-..."   # your gateway key
export ANTHROPIC_MODEL="zai/glm-5.2"       # any provider/model id the gateway serves
export ANTHROPIC_API_KEY=""                # clear this — see note below
claude
```

<Note>
  Claude Code sends `ANTHROPIC_AUTH_TOKEN` as `Authorization: Bearer ...` — the header the
  gateway's key auth expects — while `ANTHROPIC_API_KEY` is sent as `x-api-key` and takes
  priority if both are set. Clear `ANTHROPIC_API_KEY` (empty string, or unset it) so
  `ANTHROPIC_AUTH_TOKEN` is what's actually used.
</Note>

`ANTHROPIC_MODEL` accepts any registered `provider/model` id (see [Models &
pricing](/docs/models)), not just Claude models — requests still arrive in Anthropic's wire
format and the gateway translates them. Add the exports to your shell profile to make
them permanent, or prefix a single run instead:

```bash theme={null}
ANTHROPIC_BASE_URL="https://api.impossibl.com" ANTHROPIC_AUTH_TOKEN="imp-rt-..." \
ANTHROPIC_MODEL="zai/glm-5.2" ANTHROPIC_API_KEY="" claude
```

## Raw HTTP

No SDK required — see the [Agent quickstart](/docs/agent-quickstart) for curl examples,
and [Streaming](/docs/streaming) for SSE.
