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

# OpenAI SDK

> Detailed guide to using the official OpenAI SDK with KiosAPI across Python and Node.js.

# Using the OpenAI SDK with KiosAPI

KiosAPI is fully compatible with the official OpenAI SDK. This means you can drop in the libraries you already use, change the base URL, and immediately access every chat model KiosAPI offers — including non-OpenAI models.

## Python SDK

### Installation

```bash theme={null}
pip install openai
```

### Configuration

```python theme={null}
import openai

openai.api_key = "sk-xxx"
openai.base_url = "https://kiosapi.com/v1/"
```

> [!WARNING]
>
> The `base_url` **must** include the `/v1/` suffix. Omitting it will result in `404 Not Found` errors.

### Chat completion example

```python theme={null}
import openai

openai.api_key = "sk-xxx"
openai.base_url = "https://kiosapi.com/v1/"

response = openai.chat.completions.create(
    model="gpt-5.5",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Write a haiku about the ocean."},
    ],
)

print(response.choices[0].message.content)
```

#### Streaming

```python theme={null}
import openai

openai.api_key = "sk-xxx"
openai.base_url = "https://kiosapi.com/v1/"

stream = openai.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Tell me a story."}],
    stream=True,
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)
```

## Node.js SDK

### Installation

```bash theme={null}
npm install openai
```

### Configuration

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

const client = new OpenAI({
  apiKey: "sk-xxx",
  basePath: "https://kiosapi.com/v1",
});
```

### Chat completion example

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

const client = new OpenAI({
  apiKey: "sk-xxx",
  basePath: "https://kiosapi.com/v1",
});

async function main() {
  const response = await client.chat.completions.create({
    model: "gpt-5.5",
    messages: [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Write a haiku about the ocean." },
    ],
  });

  console.log(response.choices[0].message.content);
}

main();
```

## Important notes

> [!TIP]
>
> **All chat models on KiosAPI — including non-OpenAI models — support the OpenAI official library.** You don't need a different SDK for Claude, Gemini, or any other model family. Just change the `model` parameter and keep the same client configuration.

> [!WARNING]
>
> **`base_url` suffix requirement (Python):** Always set `base_url` to `https://kiosapi.com/v1/` with the trailing `/v1/`. Setting it to `https://kiosapi.com` or `https://kiosapi.com/v1` (without the trailing slash) may cause request routing failures.

## Next steps

* [Quickstart](https://docs.kiosapi.com/getting-started/quickstart.md) — minimal setup to get going fast.
* [Concurrency](https://docs.kiosapi.com/getting-started/concurrency.md) — scale up to thousands of concurrent requests.
* [API Reference](https://docs.kiosapi.com/introduction.md) — full endpoint documentation.


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