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

# Use the OpenAI Python and Node.js SDK with KiosAPI

> Learn to configure the OpenAI Python or Node.js SDK for KiosAPI — swap base URL and API key to access all chat models including Claude and Gemini.

KiosAPI is fully compatible with the official OpenAI SDK. Swap in your KiosAPI base URL and API key, and every line of existing code continues to work — no other changes required. You get instant access to all chat models KiosAPI offers, including non-OpenAI models.

<Tabs>
  <Tab title="Python">
    ### Installation

    Install the OpenAI Python package with pip:

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

    ### Configuration

    Set your API key and point the base URL at KiosAPI:

    ```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 with a trailing slash. Omitting it will result in `404 Not Found` errors on every request.
    </Warning>

    ### Chat Completion

    Send a basic chat completion request using the configured client:

    ```python theme={null}
    import openai

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

    response = openai.chat.completions.create(
        model="gpt-4o-mini",
        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

    Enable streaming by passing `stream=True` and iterating over the returned chunks:

    ```python theme={null}
    import openai

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

    stream = openai.chat.completions.create(
        model="gpt-4o-mini",
        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)
    ```
  </Tab>

  <Tab title="Node.js">
    ### Installation

    Install the OpenAI Node.js package with npm:

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

    ### Configuration

    Instantiate the client with your API key and KiosAPI base URL:

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

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

    ### Chat Completion

    Send a chat completion request using the configured client:

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

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

    async function main() {
      const response = await client.chat.completions.create({
        model: "gpt-4o-mini",
        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();
    ```
  </Tab>
</Tabs>

<Tip>
  **Every chat model on KiosAPI — including Claude and Gemini — works with the OpenAI SDK.** You do not need a separate SDK for non-OpenAI model families. Change only the `model` parameter and keep the same client configuration.
</Tip>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/getting-started/quickstart">
    Minimal setup to make your first KiosAPI request in under a minute.
  </Card>

  <Card title="Concurrency" icon="bolt" href="/getting-started/concurrency">
    Scale up to thousands of parallel requests using asyncio and aiohttp.
  </Card>
</CardGroup>
