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

# OpenAI SDKs

> Use the official OpenAI Python and Node.js SDKs with RefillAPI.

RefillAPI speaks the OpenAI API, so the official SDKs work as they are. Change two things: the base URL and the API key.

> [tab] Python
>
> ```bash theme={null}
> pip install openai
> ```
>
> ```python theme={null}
> import os
> from openai import OpenAI
>
> client = OpenAI(
>     api_key=os.environ["REFILLAPI_KEY"],
>     base_url="https://refillapi.com/v1",
> )
> response = client.chat.completions.create(
>     model="deepseek-v4-pro",
>     messages=[{"role": "user", "content": "Introduce yourself in one sentence."}],
> )
> print(response.choices[0].message.content)
> ```

> [tab] Node.js
>
> ```bash theme={null}
> npm install openai
> ```
>
> ```javascript theme={null}
> import OpenAI from "openai";
>
> const client = new OpenAI({
>   apiKey: process.env.REFILLAPI_KEY,
>   baseURL: "https://refillapi.com/v1",
> });
> const response = await client.chat.completions.create({
>   model: "deepseek-v4-pro",
>   messages: [{ role: "user", content: "Introduce yourself in one sentence." }],
> });
> console.log(response.choices[0].message.content);
> ```

Set the key in your shell first: `export REFILLAPI_KEY='sk-...'`.

## Other tools

Any tool with a custom "OpenAI-compatible" provider works the same way: base URL `https://refillapi.com/v1`, your API key, and an exact model ID. Many frameworks (LangChain, LlamaIndex, Vercel AI SDK, LiteLLM) read the `OPENAI_BASE_URL` and `OPENAI_API_KEY` environment variables.

## Non-OpenAI fields

Model-specific fields — for example `metadata` on video requests or `images` on image requests — are passed with `extra_body` in Python and as extra properties in Node.js:

```python theme={null}
client.images.generate(
    model="wan2.7-image-pro",
    prompt="Put this product on a white studio background",
    extra_body={"images": ["https://example.com/product.jpg"]},
)
```

Keep the key on the server. Do not ship it in browser or mobile app code.


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