OpenAI-compatible API examples - Poolside

Prerequisites

Before you get started, you need:

  1. An API key for your access method: a Poolside Platform API key, an API key for your organization’s Poolside deployment, or an OpenRouter API key. To get a key and send it with Bearer authentication, see Authenticate API requests.
  2. curl or another tool that can make API requests.

List available models

Most API requests require you to pass a model id. To get all available models and their ids:

List models

curl --request GET \
  --url https://inference.poolside.ai/v1/models \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Authorization: Bearer <api-key>'

Response example

{
  "data": [
    {
      "id": "poolside/laguna-s-2.1",
      "created": 1751637312,
      "owned_by": "system",
      "object": "model"
    }
  ],
  "object": "list"
}

In this case, the response includes one model with the id poolside/laguna-s-2.1.

This request does not require an API key. The response is not limited to Poolside models, so this example pipes the output to jq to filter for Poolside model id values:

List models

curl --silent --request GET \
  --url https://openrouter.ai/api/v1/models |
  jq '[.data[] | select(.id | startswith("poolside/")) | {id, name}]'

Response example

[
  {
    "id": "poolside/laguna-s-2.1",
    "name": "Poolside: Laguna S 2.1"
  },
  {
    "id": "poolside/laguna-s-2.1:free",
    "name": "Poolside: Laguna S 2.1 (free)"
  }
]

OpenRouter may offer free and paid Poolside models. To see current availability in the browser, see Poolside models on OpenRouter.

Send a chat prompt

To generate completions from a model, you need the model id and your prompt formatted as content inside messages with the user role:

Send chat prompt

curl --request POST \
  --url https://inference.poolside.ai/v1/chat/completions \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <api-key>' \
  --data '{
  "messages": [
    {
      "content": "Explain cURL",
      "role": "user"
    }
  ],
  "model": "poolside/laguna-s-2.1"
}'

Response example

{
  "model": "poolside/laguna-s-2.1",
  "created": 1751993576,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "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
  }
}

Turn off thinking through the Poolside API

Some Poolside models support per-request thinking control through Poolside API chat template settings. To turn off thinking, set chat_template_kwargs.enable_thinking to false:

Turn off thinking

curl --request POST \
  --url https://inference.poolside.ai/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <api-key>' \
  --data '{
    "model": "poolside/laguna-s-2.1",
    "messages": [
      {
        "role": "user",
        "content": "What are channels in Go?"
      }
    ],
    "chat_template_kwargs": {
      "enable_thinking": false
    }
  }'

OpenAI-compatible tool calling behavior can vary by model and serving configuration. If you need to force a specific function call with tool_choice, such as "required" or a named function, try turning off thinking first by setting chat_template_kwargs.enable_thinking to false.

Control reasoning through OpenRouter

To control reasoning effort through OpenRouter-compatible models, include a reasoning object:

{
  "model": "<model-id>",
  "messages": [
    {
      "content": "Explain cURL",
      "role": "user"
    }
  ],
  "reasoning": {
    "effort": "max"
  }
}

OpenRouter’s generic effort values are max, xhigh, high, medium, low, minimal, and none, but provider and model support varies.

Stream responses

For example, if you want to receive your response as a series of completion chunks returned as server-sent events, set stream to true. This is useful for real-time applications.

Stream chat prompt

curl --request POST \
  --url https://inference.poolside.ai/v1/chat/completions \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <api-key>' \
  --data '{
  "messages": [
    {
      "content": "Explain cURL",
      "role": "user"
    }
  ],
  "model": "poolside/laguna-s-2.1",
  "stream": true
}'

Response example

data: {"model":"poolside/laguna-s-2.1","created":1754035552,"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":""}]}

data: {"model":"poolside/laguna-s-2.1","created":1754035552,"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"cURL","role":"assistant"},"finish_reason":""}]}

...

Send a chat prompt with extra context

Optionally, you can add more context to a query. This is useful when you want to give the model information it does not have.

Ask without context

curl --request POST \
  --url https://inference.poolside.ai/v1/chat/completions \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <api-key>' \
  --data '{
  "messages": [
    {
      "content": "What is my name?",
      "role": "user"
    }
  ],
  "model": "poolside/laguna-s-2.1"
}'

Ask with context

curl --request POST \
  --url https://inference.poolside.ai/v1/chat/completions \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <api-key>' \
  --data '{
  "messages": [
    {
      "content": "path:/Users/name/Desktop/userinfo content:My name is Jason. Question: What is my name?",
      "role": "user"
    }
  ],
  "model": "poolside/laguna-s-2.1"
}'

In the previous snippet, the message provides context about the user’s name. If you run this example, the response takes this information into account.

Response example

{
  "model": "poolside/laguna-s-2.1",
  "created": 1751993576,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "content": "Based on the provided context, your name is Jason.",
        "role": "assistant"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "completion_tokens": 15,
    "prompt_tokens": 693,
    "total_tokens": 708
  }
}

Extend models with tools

You can extend your model’s capabilities by providing tools (functions) that the model can call during conversations.

Define a tool

curl --request POST \
  --url https://inference.poolside.ai/v1/chat/completions \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <api-key>' \
  --data '{
  "model": "poolside/laguna-s-2.1",
  "messages": [
    {
      "role": "user",
      "content": "what is the weather forecast for San Francisco"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_forecast",
        "description": "Get weather forecast for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string",
              "description": "City name"
            }
          },
          "required": [
            "city"
          ],
          "additionalProperties": false
        }
      }
    }
  ]
}'

When the model needs to use a tool, it responds with a tool_calls array in the model response message.