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

# Poolside API

> Choose an access method, authenticate, and send your first request to the Poolside OpenAI-compatible API.

Call Poolside models through an OpenAI-compatible API. This page covers access methods, available endpoints, authentication, and your first request with cURL or an OpenAI-compatible SDK.

## Access methods

The API base URL depends on how you access Poolside.

| Access method | Base URL |
| - | - |
| Poolside-hosted inference | `https://inference.poolside.ai/v1` |
| Self-managed Poolside inference | `https://<model-hostname>/v1`, or the base URL exposed by an inference gateway |
| OpenRouter | `https://openrouter.ai/api/v1` |

## Available endpoints

Poolside-hosted inference supports these endpoints:

| Method | Endpoint | What it's for |
| - | - | - |
| `GET` | [`/v1/models`](https://docs.poolside.ai/inference-api/models/list-models) | List available models |
| `POST` | [`/v1/chat/completions`](https://docs.poolside.ai/inference-api/chat/create-chat-completion) | Generate a response from a conversation |

## Authentication

### Get an API key

Get the API key for your access method:

* **Poolside-hosted inference**: Sign in to [Poolside Platform](https://platform.poolside.ai/), open the **API Keys** tab, and click **New key**.
* **OpenRouter**: Go to [OpenRouter API keys](https://openrouter.ai/keys), sign in, and create an API key.
* **Self-managed Poolside inference**: Use the API key configured for your model endpoint or inference gateway. If API key authentication is off, you do not need a key.

### Send the API key

Poolside-hosted inference and OpenRouter require an API key. Send it as a Bearer token in the `Authorization` header:

```text theme={null}
Authorization: Bearer <api-key>
```

Authentication for self-managed Poolside inference depends on how your endpoint or gateway is configured. If API key authentication is off, omit the `Authorization` header.

API keys are secrets. Store them securely and never commit them to source control.

## Make your first API call

This quickstart uses Poolside-hosted inference and the [`poolside/laguna-s-2.1`](https://docs.poolside.ai/api/openai-api-examples#list-available-models) model ID.

**Prerequisites**

* An API key from [Poolside Platform](https://platform.poolside.ai/)
* `curl`, Python, or Node.js

**Steps**

> [tab] cURL
>
> **1. Set your API key**
>
> Export your API key as an environment variable. The cURL command below reads it from `$POOLSIDE_API_KEY`.
>
> ```bash theme={null}
> export POOLSIDE_API_KEY="<api-key>"
> ```
>
> **2. Make your first API call**
>
> Send a `POST` request to the Chat Completions endpoint:
>
> ```bash theme={null}
> curl https://inference.poolside.ai/v1/chat/completions \
>   -H "Authorization: Bearer $POOLSIDE_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "poolside/laguna-s-2.1",
>     "messages": [{ "role": "user", "content": "Explain cURL" }]
>   }'
> ```
>
> Poolside returns a JSON response containing the message:
>
> ```json title="Response example" theme={null}
> {
>   "id": "chatcmpl-abc123",
>   "model": "poolside/laguna-s-2.1",
>   "created": 1751993576,
>   "object": "chat.completion",
>   "choices": [
>     {
>       "index": 0,
>       "message": {
>         "reasoning_content": "The user is asking what cURL is. I should explain that it is a command-line tool, name the protocols it supports, and give the common uses...",
>         "content": "cURL is a powerful command-line tool used for transferring data to or from a server, supporting various protocols such as HTTP, HTTPS, FTP, and more. It's widely used for testing APIs, downloading files, and automating HTTP requests. cURL allows you to specify headers, methods (GET, POST, PUT, DELETE, etc.), and data payloads, making it versatile for a range of web-related tasks.\n",
>         "role": "assistant"
>       },
>       "finish_reason": "stop"
>     }
>   ],
>   "usage": {
>     "completion_tokens": 88,
>     "prompt_tokens": 447,
>     "total_tokens": 535
>   }
> }
> ```
>
> Poolside-hosted inference enables thinking by default, so the response can include `reasoning_content` in addition to `content`. See [OpenAI-compatible API examples](https://docs.poolside.ai/api/openai-api-examples.md#turn-off-thinking) to turn it off.

> [tab] Python
>
> **1. Set your API key**
>
> Export your API key as an environment variable.
>
> ```bash theme={null}
> export POOLSIDE_API_KEY="<api-key>"
> ```
>
> **2. Install the OpenAI SDK**
>
> ```bash theme={null}
> pip install openai
> ```
>
> **3. Create your code**
>
> Create a file called `quickstart.py`. The code below reads your key from `POOLSIDE_API_KEY`:
>
> ```python title="quickstart.py" theme={null}
> import os
> from openai import OpenAI
>
> client = OpenAI(
>     api_key=os.environ["POOLSIDE_API_KEY"],
>     base_url="https://inference.poolside.ai/v1",
> )
>
> completion = client.chat.completions.create(
>     model="poolside/laguna-s-2.1",
>     messages=[{"role": "user", "content": "Explain cURL"}],
> )
>
> print(completion.choices[0].message.content)
> ```
>
> **4. Run your code**
>
> ```bash theme={null}
> python quickstart.py
> ```

> [tab] TypeScript
>
> **1. Set your API key**
>
> Export your API key as an environment variable.
>
> ```bash theme={null}
> export POOLSIDE_API_KEY="<api-key>"
> ```
>
> **2. Install the OpenAI SDK and tsx**
>
> `tsx` runs the TypeScript file directly.
>
> ```bash theme={null}
> npm install openai tsx
> ```
>
> **3. Create your code**
>
> Create a file called `quickstart.ts`. The code below reads your key from `POOLSIDE_API_KEY`:
>
> ```typescript title="quickstart.ts" theme={null}
> import OpenAI from "openai";
>
> const client = new OpenAI({
>   apiKey: process.env.POOLSIDE_API_KEY,
>   baseURL: "https://inference.poolside.ai/v1",
> });
>
> const completion = await client.chat.completions.create({
>   model: "poolside/laguna-s-2.1",
>   messages: [{ role: "user", content: "Explain cURL" }],
> });
>
> console.log(completion.choices[0].message.content);
> ```
>
> **4. Run your code**
>
> ```bash theme={null}
> npx tsx quickstart.ts
> ```

> [!NOTE]
>
> To use OpenRouter instead, use `https://openrouter.ai/api/v1` as the base URL or SDK `base_url`/`baseURL`, pass your OpenRouter API key, and replace the model ID with an OpenRouter model ID.

## Use the API for CLI automation

For interactive Poolside Agent CLI access, see [Log in to Poolside](https://docs.poolside.ai/get-started/log-in.md).

For CLI automation against an OpenAI-compatible endpoint, configure `POOLSIDE_STANDALONE_BASE_URL`, `POOLSIDE_STANDALONE_MODEL`, and `POOLSIDE_API_KEY`. If the endpoint does not validate API keys, use any non-empty value for `POOLSIDE_API_KEY`, such as `local-test`. See [Automate tasks](https://docs.poolside.ai/cli/automated-mode.md#basic-usage).

## Next steps

* [OpenAI-compatible API examples](https://docs.poolside.ai/api/openai-api-examples.md) for generation controls, thinking control, streaming, and tool calling
* [Supported models](https://docs.poolside.ai/get-started/supported-models.md) for model guidance, context windows, and modes
* [Editors](https://docs.poolside.ai/tools.md#editors) to use Poolside from editors and editor extensions
* [Desktop apps](https://docs.poolside.ai/tools.md#desktop-apps) to use Poolside from desktop apps


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