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? You don't need to change your model field. Any model value is accepted — Sansa ignores it and auto-routes regardless. Just swap baseURL and API key.

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