Skip to main content
This page builds on Make your first API call with examples for listing models, interpreting responses, controlling generation and thinking, streaming responses, and using tools. For request parameters and response schemas, see List models and Create chat completion. The examples use Poolside-hosted inference. For other access methods, see Access methods. You may need to adapt an example for another access method because base URLs, model IDs, and supported parameters can differ. For OpenRouter, use the sections that name OpenRouter explicitly, and check the supported_parameters field in OpenRouter’s model metadata before adapting any other example.

Prerequisites

Before you get started, you need:
  1. Any authentication required by your access method: a Poolside Platform or OpenRouter API key, or the authentication configured for your self-managed model endpoint or gateway. To configure authentication, see Authentication.
  2. curl or another tool that can make API requests.
If API key authentication is off for your model endpoint or gateway, omit the Authorization header.

List available models

Most API requests require a model id. For the full request and response reference, see List models.
List models
OpenRouter serves models from many providers, so filter its catalog for Poolside model IDs. This request does not require an API key:
List Poolside models on OpenRouter
Response example
OpenRouter may offer free and paid Poolside models with different context lengths. To see current availability in the browser, see Poolside models on OpenRouter.

Read a chat response

A chat completion returns the model’s message and the tokens the request used. The response below is abbreviated for readability:
Response example
Poolside-hosted inference enables thinking by default. Responses from models that think can include reasoning_content in addition to content. The usage object reports the tokens used by the request and response. Poolside-hosted inference responses do not include logprobs or stop_reason. To give the model information it does not have, put that context in the message content as ordinary text. For guidance on what to include, see the Prompting guide.

Control generation

Poolside-hosted inference supports these generation parameters: Include only the values you want to override:
Set generation parameters

Turn off thinking

Poolside-hosted inference enables thinking by default. To turn it off for a request, set chat_template_kwargs.enable_thinking to false:
Turn off thinking
The response returns the answer in content and sets reasoning_content to null.

Preserve reasoning in agentic workflows

For agentic workflows with Poolside models, preserve reasoning_content from assistant responses when you include those responses in follow-up requests. Dropping previous reasoning content can prevent the model from reasoning in later steps. For examples, see the Control reasoning sections on the Laguna model pages.

Stream responses

To receive the response as a series of chunks returned as server-sent events, set stream to true. This is useful for real-time applications. Poolside-hosted inference includes a running token usage total on every chunk and the completed total on the final chunk. Setting stream_options.include_usage to false does not suppress these totals:
Stream chat prompt
Generation chunks carry a delta object. When a model produces reasoning, the stream returns reasoning_content before content. The stream ends with a chunk that has an empty choices array and the completed usage object. Chunks below are abbreviated for readability; each also includes created and model:
Response example

Extend models with tools

You can extend a model’s capabilities by providing tools that it can call during a conversation. This lets the model retrieve real-time data, run calculations, or interact with external systems. Poolside-hosted inference allows parallel tool calls by default. Set parallel_tool_calls to false when you want the model to call at most one tool in a response. Tool calling takes two requests. First, include a tools array and define the functions the model can call:
Define a tool
When the model needs a tool, it returns a tool_calls array and a finish_reason of tool_calls. The arguments value is a JSON string:
Response example
Second, run the tool yourself and send the result back. Include the original user message, the assistant message containing the tool_calls, and a tool message whose tool_call_id matches. Copy the assistant message from the previous response rather than rebuilding it, so that reasoning_content travels with it when the model returned it. The assistant message below is abbreviated for readability:
Send a tool result
The model then answers using the tool result.

Control reasoning through OpenRouter

OpenRouter uses its own reasoning object rather than chat_template_kwargs. To control reasoning effort for OpenRouter-compatible models, include a reasoning object:
OpenRouter’s generic effort values are max, xhigh, high, medium, low, minimal, and none, but provider and model support varies. Replace <model-id> and max with values that your selected model supports. To check which parameters a model accepts, see the supported_parameters field in OpenRouter’s model metadata.
The reasoning field is OpenRouter-style: a top-level object, which differs from the OpenAI Chat Completions reasoning_effort parameter. Use it only with OpenRouter or another provider that accepts this field. A direct connection to the OpenAI Chat Completions API at https://api.openai.com/v1/chat/completions rejects the reasoning field.Effort-level support varies by provider and model. Some providers ignore effort settings or apply thinking automatically. Check your provider’s documentation for how it handles the reasoning field.