# API surfaces

> sference serves three request shapes — the OpenAI Chat API, the OpenAI Responses API, and the Anthropic Messages API — over one catalog, one key, and one bill.

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

sference speaks three request shapes. Pick the one your code already uses; all three reach the same models, the same key, and the same billing surface.

| Surface | Endpoint | Shape | Reference |
| --- | --- | --- | --- |
| **OpenAI Chat API** | `POST /v1/chat/completions` | OpenAI | [OpenAI Chat API](https://sference.com/docs/api/chat-completions) |
| **OpenAI Responses API** | `POST /v1/responses` | OpenAI | [OpenAI Responses API](https://sference.com/docs/api/responses) |
| **Anthropic Messages API** | `POST /v1/messages` | Anthropic | [Anthropic Messages API](https://sference.com/docs/api/messages) |

## Which one

| You have | Use | Why |
| --- | --- | --- |
| OpenAI-shaped code, most SDKs and frameworks | **OpenAI Chat API** | The widest compatibility; every OpenAI client speaks it. Also takes `service_tier: "flex"` |
| A new integration, or you want background execution | **OpenAI Responses API** | Adds `background: true`, streams, and the 24h window |
| Anthropic-shaped code, Claude Code, `ChatAnthropic` | **Anthropic Messages API** | Native Anthropic bodies; no translation layer. Realtime only |
| Thousands of rows to run offline | **Batches** | One job, one model, results as JSONL on the [24h window](https://sference.com/docs/guides/batches) |

All four share one catalog, one API key, and one billing surface. The three request shapes are OpenAI- or Anthropic-compatible, so switching is a base URL and a model id — no code changes. `/v1/messages` is realtime only; see [Not supported](https://sference.com/docs/api/messages#not-supported).

## What each surface supports

| Capability | OpenAI Chat API | OpenAI Responses API | Anthropic Messages API |
| --- | --- | --- | --- |
| Realtime | ✅ | ✅ | ✅ |
| Flex (`service_tier: "flex"`) | ✅ | ✅ | ❌ |
| Background / 24h window | ❌ | ✅ | ❌ |
| Streaming | ✅ | ✅ | ✅ |
| Tools | ✅ | ✅ | ✅ |
| Structured output | ✅ `response_format` | ✅ `text.format` | ❌ |
| Vision | ✅ | ✅ | ✅ |
| Reasoning control | ✅ | ✅ | ✅ |
| `prompt_cache_key` | ✅ | ✅ | ❌ |
| `max_queue_wait_s` | ✅ | ✅ | ✅ |
| Streams (`metadata.stream_id`) | ❌ | ✅ | ❌ |
| Webhooks | ✅ | ✅ | ❌ |

The full field-by-field grid is on [API compatibility](https://sference.com/docs/compatibility), and the single-page endpoint list is on the [Support matrix](https://sference.com/docs/support).

## Base URLs

| Surface | Base URL |
| --- | --- |
| OpenAI-shaped (OpenAI Chat API, OpenAI Responses API) | `https://api.sference.com/v1` |
| Anthropic-shaped (Anthropic Messages API) | `https://api.sference.com` |

One API key (`sk_...`) authenticates all three. `/v1/messages` accepts `x-api-key` as well as `Authorization: Bearer`; the OpenAI-shaped surfaces use the bearer header.

## Common to all three

- **Model ids are catalog ids** — `zai-org/GLM-5.3`, `moonshotai/Kimi-K3`. There are no `gpt-*` or `claude-*` aliases. `GET /v1/models` lists what your key can call.
- **The API is stateless.** Every request is answered from the body you send; there is no server-side conversation to point at. Pass the full conversation each turn.
- **Prefix caching is automatic.** Keep the stable part of the prompt first; cached tokens bill at the cached-input rate. See [Prompt caching](https://sference.com/docs/guides/prompt-caching).
- **`max_queue_wait_s` bounds the wait** on all three, so you can fail over instead of hanging. See [Max queue wait](https://sference.com/docs/guides/max-queue-wait).

- [OpenAI Chat API](https://sference.com/docs/api/chat-completions): The OpenAI-shaped surface most clients already speak.
- [OpenAI Responses API](https://sference.com/docs/api/responses): Background execution, streams, and the 24h window.
- [Anthropic Messages API](https://sference.com/docs/api/messages): Anthropic-compatible bodies for the anthropic SDKs and Claude Code.
- [API compatibility](https://sference.com/docs/compatibility): Every field, what is honored, and what is ignored.
