Quickstart: self-host
Run the open-source gateway with Docker and your own OpenRouter key, and make a first call.
On this page
At the end you will have the gateway on http://localhost:8095, reaching models with your own OpenRouter key.
Start the gateway
compose.yaml services: ai: image: ghcr.io/sespinosav/sypnia-ai:1 ports: ["8095:8095"] environment: SYPNIA_GATEWAY_DATABASE_URL: postgres://sypnia:sypnia@db:5432/sypnia_ai SYPNIA_GATEWAY_ROOT_TOKEN: ${SYPNIA_GATEWAY_ROOT_TOKEN} SYPNIA_GATEWAY_OPENROUTER_KEY: ${OPENROUTER_API_KEY} SYPNIA_GATEWAY_AUTO_MIGRATE: "true" depends_on: [db] db: image: postgres:16 environment: { POSTGRES_USER: sypnia, POSTGRES_PASSWORD: sypnia, POSTGRES_DB: sypnia_ai }Terminal export SYPNIA_GATEWAY_ROOT_TOKEN=$(openssl rand -hex 32) docker compose up -d curl -s http://localhost:8095/v1/healthYou should see{"status":"ok","providers":{"openrouter":"ok"}}Give a task its route
A self-hosted gateway has no default model, on purpose: you choose it. List what your key can reach, then write the route with that id.
Terminal export SYPNIA_AI_URL=http://localhost:8095 SYPNIA_AI_TOKEN=$SYPNIA_GATEWAY_ROOT_TOKEN npx @sypnia/ai models --task writesypnia.toml [ai.tasks.write] model = "openrouter/<model id from the list>" instructions = "You write for La Espiga, a neighbourhood bakery. Warm, short, in Spanish."Terminal npx @sypnia/ai routes apply npx @sypnia/ai keys create la-espiga-server --scope callCall it
The API speaks the same language as OpenAI’s, so
curlor any OpenAI client works:Terminal curl -s http://localhost:8095/v1/chat/completions \ -H "Authorization: Bearer $SYPNIA_SECRET_KEY" \ -H "Sypnia-Case: publish-bread-of-the-day" \ -H "Content-Type: application/json" \ -d '{"model":"task:write","messages":[{"role":"user","content":"Today: rye loaf."}]}'You should seeAchat.completionobject, with asypniafield carrying the route, the model used and the cost in your provider’s currency.
Next: send the spans to Telemetry with SYPNIA_GATEWAY_OTLP_ENDPOINT (Configuration), and add Amazon Bedrock or a local model (Providers).