Quickstart

Get your first Sansa API response in under 2 minutes.

Create an API key

Create an API key in your dashboard. Store it somewhere safe, then export it as an environment variable:

export SANSA_API_KEY="sk-sansa-..."

Install the OpenAI SDK

Sansa is compatible with the standard OpenAI SDKs.

npm install openai
pip install openai

Make your first request

Create a file and copy in the example from the code panel. The only difference from OpenAI is baseURL and your Sansa API key.

Run it. You should see a response in a few seconds.

Migrating an existing app? Use "sansa-auto" to let Sansa pick the best model for each request, or keep a specific model ID (e.g. "openai/gpt-5.4") to call it directly. See Models for the full list and behavior of each mode.

Stream a response

Set stream: true to get tokens as they're generated. See the code panel for a full example.

Streaming uses Server-Sent Events (SSE) and works with the OpenAI SDK. See the Streaming docs for chunk format and error handling.

Call a function

Define tools and the model will call them when relevant. Your code executes the function and sends the result back. See the code panel for the flow.

Full details in the Tools docs.

Next steps

  • Completions Reference — Full parameter reference, including image and audio inputs
  • Models — Auto-routing, calling specific models, and provider failover
  • Transcriptions — Transcribe audio files to text
  • Streaming — SSE format, chunk shape, error handling
  • Tools — Function calling and agentic loops
  • Reasoning — Extended thinking tokens