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

# OpenAI API Compatibility — Boole AI Integration Guide

> Boole AI implements the full OpenAI API spec. Swap your base URL and API key and every existing SDK, tool, and integration works instantly.

Boole AI implements the OpenAI API specification end-to-end. Any code, tool, or integration that already works with OpenAI works with Boole — change the base URL and API key, and you're done. No new SDKs, no wrapper libraries, no refactoring required.

## What's Compatible

Boole AI supports the following endpoints and features from the OpenAI specification:

<CardGroup cols={2}>
  <Card title="POST /v1/chat/completions" icon="comments">
    Chat completions with streaming, tool calls, and structured outputs.
  </Card>

  <Card title="POST /v1/completions" icon="file-lines">
    Legacy text completions for single-turn prompts.
  </Card>

  <Card title="GET /v1/models" icon="list">
    List all models available on your account.
  </Card>

  <Card title="POST /v1/audio/transcriptions" icon="microphone">
    Audio transcription powered by Whisper Large v3.
  </Card>
</CardGroup>

Beyond endpoints, the following API-level features are fully supported:

* **Streaming** via server-sent events (SSE) — set `stream: true` in any chat or completion request
* **Tool / function calling** — pass a `tools` array and handle `tool_calls` in the response
* **JSON mode and structured outputs** — set `response_format: { type: "json_object" }` or supply a JSON schema
* **System prompts, temperature, top\_p, max\_tokens, and stop sequences** — all standard sampling parameters work as documented

## Configuration

Switch between the Boole Cloud API and a locally running binary by changing two values.

<Tabs>
  <Tab title="Cloud API">
    ```python theme={null}
    base_url = "https://api.boole.dev/v1"
    api_key  = os.environ["BOOLE_API_KEY"]
    ```
  </Tab>

  <Tab title="Local Binary">
    ```python theme={null}
    base_url = "http://localhost:8000/v1"
    api_key  = "any-non-empty-string"
    ```

    The local binary does not validate API keys. Pass any non-empty string to satisfy the SDK's requirement for an `api_key` argument.
  </Tab>
</Tabs>

## Drop-In Example

The migration from OpenAI to Boole is a two-line change. Everything else — messages format, model parameters, response parsing — stays identical.

<CodeGroup>
  ```python Before (OpenAI) theme={null}
  from openai import OpenAI

  client = OpenAI(api_key="sk-...")
  ```

  ```python After (Boole Cloud API) theme={null}
  from openai import OpenAI
  import os

  client = OpenAI(
      base_url="https://api.boole.dev/v1",
      api_key=os.environ["BOOLE_API_KEY"],
  )
  ```

  ```python After (Boole Local) theme={null}
  from openai import OpenAI

  client = OpenAI(
      base_url="http://localhost:8000/v1",
      api_key="local",
  )
  ```
</CodeGroup>

## Streaming

Enable streaming by passing `stream=True`. The SDK surfaces each token as a delta chunk as Boole sends it — at up to 312 tokens/sec on Llama 3.3 70B, the response starts appearing almost immediately.

```python streaming.py theme={null}
for chunk in client.chat.completions.create(
    model="llama-3.3-70b-instruct",
    messages=[{"role": "user", "content": "Tell me a story."}],
    stream=True,
):
    print(chunk.choices[0].delta.content or "", end="")
```

## Tool Calls

Pass a `tools` array exactly as you would with the OpenAI SDK. Boole returns a `tool_calls` field in the response when the model decides to invoke a function.

```python tool_calls.py theme={null}
tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather for a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name"}
                },
                "required": ["location"],
            },
        },
    }
]

response = client.chat.completions.create(
    model="llama-3.3-70b-instruct",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=tools,
)
```

<Note>
  Model names in Boole differ from OpenAI's. When migrating, update your `model` string — for example, replace `"gpt-4"` with `"llama-3.3-70b-instruct"`. Run `GET /v1/models` or check the [Models](/concepts/models) page for the full list of available model IDs.
</Note>
