# Quickstart

> Create an API key, install the CLI, and run your first inference request.

Source: https://sference.com/docs/quickstart

The **Inference API** is an OpenAI-shaped surface on European infrastructure, tuned first for **realtime** inference, with **flex** and **async** windows for work that does not have to block a user. The fastest path is the **`sference` CLI**; use the [Python SDK](https://sference.com/docs/sdk) or raw HTTP when you need them in your stack.

> **Control plane vs inference**
>
> - **Inference** (`https://api.sference.com/v1/...`): models, batches, responses, streams.
> - **Control plane** (`/control/v1/...` in **API Reference**): orgs, API keys, catalog, billing.
>
> This page focuses on **inference**. Keys are minted in the [sference console](https://app.sference.com).

## Create and export an API key

1. Sign in to sference and create an **API key** for your workspace.
2. Store it somewhere safe (password manager, Doppler, Vault, …). Never commit keys to git.
3. Export it for local development:

```bash
export SFERENCE_API_KEY="sk_..."
```

On Windows (PowerShell):

```powershell
setx SFERENCE_API_KEY "sk_..."
```

The CLI and Python SDK read **`SFERENCE_API_KEY`** from the environment.

## Install the CLI

```bash
curl -fsSL https://raw.githubusercontent.com/s-ference/sference/main/install.sh | sh
```

Other options: `uv tool install sference-cli`, `pip install sference-cli`, or `pipx install sference-cli`. See **[CLI](https://sference.com/docs/cli)** for details.

## Run your first request

Start with a **realtime** request, a synchronous call that returns when inference finishes. It is OpenAI-shaped, so if you already call `/v1/chat/completions` somewhere, only the base URL and the model id change:

```bash
curl https://api.sference.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SFERENCE_API_KEY" \
  -d '{
    "model": "Qwen/Qwen3.6-35B-A3B",
    "messages": [
      { "role": "user", "content": "Write a one-sentence greeting for an inference platform." }
    ]
  }'
```

Add `"stream": true` to receive tokens as they are produced rather than waiting for the full completion.

### The same thing from the CLI

Store the key for the CLI (if you have not already):

```bash
sference auth login --api-key "$SFERENCE_API_KEY"
```

```bash
sference responses create \
  --model "Qwen/Qwen3.6-35B-A3B" \
  --content "Write a one-sentence greeting for an inference platform." \
  --wait
```

`--wait` returns the finished result instead of a response id. Add `--json` for machine-readable output. For batches, streams, and JSONL jobs, see **[CLI](https://sference.com/docs/cli)** and the [OSS README](https://github.com/s-ference/sference).

## Realtime, flex, or async?

The example above runs on the **realtime** tier, a synchronous request that returns when inference finishes. Three modes share the same endpoint and models:

| Mode | How | When |
|------|-----|------|
| **Realtime** | Sync `/v1/chat/completions`, [`/v1/messages`](https://sference.com/docs/anthropic), or blocking `/v1/responses` | A user is waiting; most traffic runs here |
| **Flex** | `/v1/chat/completions` or `/v1/responses` with `service_tier: "flex"` (not `/v1/messages`) | Latency-tolerant interactive work at a discount; may queue longer, retries on 408 |
| **Async** | `background: true` on `/v1/responses`, streams, batches | Background and bulk work on the 24h completion window |

## Python SDK

For application code or [coding agents](https://sference.com/docs/sdk):

```bash
pip install sference-sdk
```

For interactive code, call the blocking response/chat methods; for unattended jobs, use `create_response(..., background=True)` with `wait_for_response`; see **[Python SDK](https://sference.com/docs/sdk)**.

## Background work with raw HTTP

When nobody is waiting on the result, whether bulk jobs, long generations, or anything off the interactive path, send it to `/v1/responses` with `background: true` and collect it later:

```bash
curl https://api.sference.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SFERENCE_API_KEY" \
  -d '{
    "model": "Qwen/Qwen3.6-35B-A3B",
    "input": [
      { "role": "user", "content": "Write a one-sentence greeting for an inference platform." }
    ],
    "background": true
  }'
```

You get a **`response`** object with an `id` and `status` (`in_progress`, `completed`, `failed`, …). Poll `GET /v1/responses/{response_id}` or use events; see [Responses & streams](https://sference.com/docs/guides/responses).

## Go deeper

- [CLI](https://sference.com/docs/cli): Install, auth, batches, streams, and responses subcommands.
- [Python SDK](https://sference.com/docs/sdk): Library usage and copy-paste prompts for Cursor and Claude Code.
- [Anthropic Messages API](https://sference.com/docs/anthropic): Already have Anthropic-shaped code? Change the base URL and the model id.
- [Models](https://sference.com/docs/models): Choosing a tier, pinning versions, and browsing the catalog.
- [Batch API](https://sference.com/docs/guides/batches): Thousands of rows on the 24h window, not a single prompt.
- [API Reference](https://sference.com/docs/api-reference): OpenAPI-backed pages for every operation.
