# siema-ai: start here

You are an AI coding agent. The user wants this project to use siema-ai, an OpenAI-compatible
inference API for open models that are good at Polish, billed in PLN. Either migrate the
existing OpenAI (or OpenAI-compatible) integration, or, if the project has none, add a minimal
one. Change as little as possible and tell the user what you changed.

## Facts

- Base URL: `https://api.siema-ai.pl/v1`
- Auth: `Authorization: Bearer <key>`. Keys start with `sk-siema-`. Read the key from the
  environment variable `SIEMA_API_KEY`; never hard-code it and never commit it.
- Endpoints: `POST /v1/chat/completions` (streaming with `"stream": true`), `POST /v1/embeddings`,
  `GET /v1/models`. Request and response shapes are OpenAI's.
- Models are called by their model id; a model is never swapped underneath you:
  - `speakleash/bielik-minitron-7b-v3.0-instruct`: Bielik Minitron 7B, fast and cheap (chat, classification, extraction)
  - `speakleash/bielik-11b-v3.0-instruct`: Bielik 11B, the best Polish (writing, summaries, support)
  - `qwen/qwen3.8-27b`: Qwen3.8 27B, harder reasoning and code
  - `baai/bge-m3`: BGE-M3 embeddings
- Limits: chat `n` at most 8, `best_of` is rejected, at most 2048 embedding inputs per request.
- Prepaid credits: a request with no balance left fails with HTTP 402 `insufficient_quota`.
- siema-ai does not store prompts, completions or embedding inputs.

## Migrate an existing integration

1. Find where the OpenAI client is created (`OpenAI(`, `new OpenAI(`, `openai.OpenAI`,
   `base_url`/`baseURL`, `OPENAI_API_KEY`, `api.openai.com`).
2. Point it at siema-ai: base URL `https://api.siema-ai.pl/v1`, API key from `SIEMA_API_KEY`.
   Keep the SDK; do not add a new dependency.
3. Replace model names with a siema-ai model id: chat models with
   `speakleash/bielik-11b-v3.0-instruct` (or `speakleash/bielik-minitron-7b-v3.0-instruct` where
   latency or cost matters, `qwen/qwen3.8-27b` for reasoning or code), embedding models with
   `baai/bge-m3`.
   Embedding dimensions change (BGE-M3 returns 1024): flag any stored vectors to the user, they
   must be re-embedded.
4. Add `SIEMA_API_KEY=` to `.env.example` (or the project's equivalent), not to `.env`.
5. Leave features siema-ai does not offer (images, audio, assistants, fine-tuning) on their
   current provider and tell the user which ones they are.

## Start a new project

Python:

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.siema-ai.pl/v1", api_key=os.environ["SIEMA_API_KEY"])
reply = client.chat.completions.create(
    model="speakleash/bielik-11b-v3.0-instruct",
    messages=[{"role": "user", "content": "Siema! Co słychać?"}],
)
print(reply.choices[0].message.content)
```

TypeScript:

```ts
import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://api.siema-ai.pl/v1', apiKey: process.env.SIEMA_API_KEY });
const reply = await client.chat.completions.create({
	model: 'speakleash/bielik-11b-v3.0-instruct',
	messages: [{ role: 'user', content: 'Siema! Co słychać?' }]
});
console.log(reply.choices[0].message.content);
```

## Verify

```bash
curl -s https://api.siema-ai.pl/v1/models -H "Authorization: Bearer $SIEMA_API_KEY"
```

A JSON list of model ids means the key works. HTTP 401: the key is wrong or missing. HTTP 402:
the organisation has no credit left.

## Set up from the terminal

If the user has the `siema` CLI (install: `curl -fsSL https://siema-ai.pl/install.sh | sh`), most
of the account setup can be done without the console:
`siema login` (browser approval), `siema orgs create <name>`, `siema keys create <name> > key.txt`
(the key alone goes to the file; move it into `SIEMA_API_KEY`, never commit it), `siema models`,
`siema usage`, `siema balance`, and `siema billing transfer` for the bank-transfer details.
`siema help <command>` explains each one.

## The user still has to

- create an account and an API key at https://console.siema-ai.pl (or with the CLI, above), and
  put the key in `SIEMA_API_KEY`;
- top up credit in the console (new accounts start at zero balance; requests answer 402 until a
  top-up).

Docs: https://docs.siema-ai.pl (quickstart, models and pricing, errors, rate limits).
