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

# OpenAI-compatible client

> Use any OpenAI-compatible library — point at MESH by changing the base URL.

MESH speaks the OpenAI Chat Completions, Embeddings, and Models APIs verbatim. Any OpenAI-compatible
client (the official OpenAI SDK, LangChain, LlamaIndex, Vercel AI SDK, etc.) works by changing two
settings:

| Setting  | MESH value                      |
| -------- | ------------------------------- |
| Base URL | `https://api.meshrouter.app/v1` |
| API key  | `mesh_live_...`                 |

## TypeScript (official `openai` package)

```ts theme={null}
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.meshrouter.app/v1',
  apiKey: process.env.MESH_API_KEY,
});

const reply = await client.chat.completions.create({
  model: 'auto', // or "mesh/claude-sonnet-4.5"
  messages: [{ role: 'user', content: 'hello' }],
});
```

## Python (official `openai` package)

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

client = OpenAI(
    base_url="https://api.meshrouter.app/v1",
    api_key="mesh_live_...",
)

reply = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "hello"}],
)
```

## cURL

```bash theme={null}
curl https://api.meshrouter.app/v1/chat/completions \
  -H "Authorization: Bearer $MESH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mesh/claude-sonnet-4.5",
    "messages": [{"role":"user","content":"hello"}]
  }'
```

Receipt + cost metadata still come back on the response headers (`x-mesh-receipt-id`,
`x-mesh-total-usd`, `x-mesh-margin-usd`, `x-mesh-upstream-cost-usd`) regardless of which client you
use.

## When to use the native MESH SDK instead

The official OpenAI SDKs don't know about MESH-specific surfaces like payments, account balance, or
signed attestation. If you want typed helpers for those, use:

* [`@meshrouter/sdk` for TypeScript](/sdks/typescript)
* [`meshrouter` for Python](/sdks/python)

They keep the OpenAI-compatible chat shape and add typed methods for receipts, payments, usage, and
account management.
