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

# OpenAI SDK

> Use the OpenAI SDK with the Halesis API.

> [tab] JavaScript
>
> ```bash npm theme={null}
> npm install openai
> ```
>
> ```bash yarn theme={null}
> yarn add openai
> ```
>
> ```bash pnpm theme={null}
> pnpm add openai
> ```
>
> ```bash bun theme={null}
> bun add openai
> ```
>
> ```typescript theme={null}
> import OpenAI from "openai";
>
> const client = new OpenAI({
>   apiKey: process.env.HALESIS_API_KEY,
>   baseURL: "https://api.halesis.com/v1",
> });
>
> const response = await client.chat.completions.create({
>   model: "b1-fast",
>   messages: [{ role: "user", content: "Hello!" }],
> });
>
> console.log(response.choices[0]?.message.content);
> ```

> [tab] Python
>
> ```bash pip theme={null}
> pip install openai
> ```
>
> ```bash uv theme={null}
> uv add openai
> ```
>
> ```python theme={null}
> import os
> from openai import OpenAI
>
> client = OpenAI(
>     api_key=os.environ["HALESIS_API_KEY"],
>     base_url="https://api.halesis.com/v1",
> )
>
> response = client.chat.completions.create(
>     model="b1-fast",
>     messages=[{"role": "user", "content": "Hello!"}],
> )
>
> print(response.choices[0].message.content)
> ```

See the [Chat Completions API reference](https://docs.halesis.com/api-reference/chat/create-a-chat-completion.md).

Set up using a coding agent

Configure this project's existing OpenAI SDK client to use the Halesis API.

Inspect the codebase and follow its current language, SDK version, and configuration patterns. Set the API base URL to `https://api.halesis.com/v1`, read the API key from the server-side `HALESIS_API_KEY` environment variable, and use the Halesis model `b1-fast` in a Chat Completions request. Use the SDK's appropriate base URL option for the project's language (for example, `baseURL` in JavaScript/TypeScript or `base_url` in Python).

Do not use the Responses API, expose the API key in browser code, or introduce a Halesis-specific SDK. Make the smallest necessary changes and run relevant checks.


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