# OpenAI SDKs and tools
> Use Clonvo with the OpenAI SDKs and other OpenAI-compatible tools.
Anything that lets you change the OpenAI base URL can use Clonvo. Set the base URL to `https://api.clonvo.com/v1`, use your Clonvo API key, and use Clonvo [model ids](https://clonvo.com/docs/models.md).
## OpenAI Python SDK
```python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.clonvo.com/v1", api_key=os.environ["CLONVO_API_KEY"])
```
Pass Clonvo extensions such as `models` or `provider` with `extra_body`:
```python
client.chat.completions.create(
model="anthropic/claude-sonnet-5-5",
messages=messages,
extra_body={"models": ["openai/gpt-6.1-sol"], "provider": {"data_collection": "deny"}},
)
```
Read extension fields from responses with `getattr` or `model_extra`, for example `completion.usage.cost` or `completion.model_extra["provider"]`. To get the generation id from the `x-clonvo-generation-id` header, use `client.chat.completions.with_raw_response.create(…)`.
## OpenAI Node.js SDK
```js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.clonvo.com/v1", apiKey: process.env.CLONVO_API_KEY });
```
Extra request fields are sent as-is; in TypeScript, add them with a cast or `// @ts-expect-error`.
`client.responses.create(…)` and `client.responses.stream(…)` call the [Responses API](https://clonvo.com/docs/responses.md), which also runs the [OpenAI Agents SDK](https://clonvo.com/docs/responses.md#openai-agents-sdk).
## Environment variables
The OpenAI SDKs read these variables, so many tools work without code changes:
```bash
export OPENAI_BASE_URL="https://api.clonvo.com/v1"
export OPENAI_API_KEY="$CLONVO_API_KEY"
```
## Vercel AI SDK
```ts
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const clonvo = createOpenAI({ baseURL: "https://api.clonvo.com/v1", apiKey: process.env.CLONVO_API_KEY });
const { text } = await generateText({
model: clonvo.chat("google/gemini-3.8-flash"),
prompt: "Write a limerick about latency.",
});
```
Use `.chat(…)` so the SDK calls Chat Completions. The SDK’s default model calls the Responses API, which Clonvo serves [statelessly](https://clonvo.com/docs/responses.md); `.chat(…)` is the tested path with the AI SDK.
## LangChain
```python
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="mistralai/mistral-large-4",
base_url="https://api.clonvo.com/v1",
api_key=os.environ["CLONVO_API_KEY"],
)
```
## Other tools
For editors, agents and chat apps with an “OpenAI-compatible” provider option:
| Setting | Value |
| --- | --- |
| Base URL | `https://api.clonvo.com/v1` |
| API key | Your `sk-cv-v1-…` key |
| Model | Any id from the [catalogue](https://clonvo.com/models.md) |
Tools built for OpenRouter usually work with `https://clonvo.com/api/v1` as the base URL, since Clonvo accepts OpenRouter-style model ids.
## What isn’t supported
Clonvo serves `POST /v1/chat/completions`, [`POST /v1/responses`](https://clonvo.com/docs/responses.md), `POST /v1/embeddings` ([Embeddings](https://clonvo.com/docs/embeddings.md)) and the [read-only endpoints](https://clonvo.com/docs/other-endpoints.md). The OpenAI Images, Audio, Files, Batch and Assistants APIs aren’t available, so SDK methods that call them fail with `404` and the code `unknown_endpoint`. A supported path called with the wrong HTTP method, such as `GET /v1/chat/completions`, returns `405` with the code `method_not_allowed`.
## App attribution
You can send `HTTP-Referer` and `X-Title` headers to name your app, as with OpenRouter. Clonvo records them with each request: they appear in the request details in the dashboard’s activity, and as `origin` and `app_title` in [`GET /v1/generation`](https://clonvo.com/docs/other-endpoints.md#get-v1-generation). They’re also passed on to OpenRouter for free models.
```python
client = OpenAI(
base_url="https://api.clonvo.com/v1",
api_key=os.environ["CLONVO_API_KEY"],
default_headers={"HTTP-Referer": "https://example.com", "X-Title": "Example App"},
)
```