# API Reference (/docs/api)

With one OhMyGPT key you can call every model in the catalog through the OpenAI, Anthropic, or Gemini protocol. Keep the SDK your project already uses and change two settings: the base URL and the key. Create a key at [API keys](https://www.ohmygpt.com/keys).

Test your integration for free with `ohmygpt/mock`. It answers on every chat endpoint, streaming or not:

```bash
curl https://api.ohmygpt.com/v1/chat/completions \
  -H "Authorization: Bearer $OHMYGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ohmygpt/mock", "messages": [{"role": "user", "content": "ping"}]}'
```

```json
{
  "id": "chatcmpl-ohmygpt-mock",
  "object": "chat.completion",
  "model": "mock",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "This is a mock reply from OhMyGPT. Your integration works; switch to a real model when ready."
      }
    }
  ],
  "usage": { "prompt_tokens": 15, "completion_tokens": 17, "total_tokens": 32 }
}
```

When it works, change `model` to a real model ID.

## Chat protocols [#chat-protocols]

Every chat model answers on all four protocols. Use the one your SDK or tool speaks:

| Protocol | Endpoint | SDK base URL | Auth header |
|---|---|---|---|
| [OpenAI Chat Completions](/docs/api/chat-completions) | `POST /v1/chat/completions` | `https://api.ohmygpt.com/v1` | `Authorization: Bearer` |
| [OpenAI Responses](/docs/api/responses) | `POST /v1/responses` | `https://api.ohmygpt.com/v1` | `Authorization: Bearer` |
| [Anthropic Messages](/docs/api/messages) | `POST /v1/messages` | `https://api.ohmygpt.com` (no `/v1`) | `x-api-key` |
| [Gemini](/docs/api/gemini) | `POST /v1/models/{model}:generateContent` | `https://api.ohmygpt.com`, API version `v1` | `x-goog-api-key` |

`Authorization: Bearer` and `x-api-key` work on every endpoint, so each SDK's default header is accepted. `x-goog-api-key` works on the Gemini endpoints. Send the key in one header only.

[Protocols](/docs/api/protocols) shows what you send and get back when you call a model on each protocol.

## Other endpoints [#other-endpoints]

| Endpoint | Purpose |
|---|---|
| `POST /v1/messages/count_tokens` | Count input tokens for a Claude request, free |
| `POST /v1/embeddings` | Embeddings |
| `POST /v1/rerank` | Rerank documents against a query |
| `POST /v1/images/generations`, `POST /v1/images/edits` | Generate and edit images |
| `POST /v1/audio/speech`, `POST /v1/audio/transcriptions` | Text to speech, speech to text |
| `POST /v1/moderations` | Content moderation |
| `POST /v1/ocr` | Extract text from documents |
| [`POST /v1/decisions`](/docs/api/decisions) | Typed answers to classification questions |
| [`POST /v1/systemone`](/docs/api/decisions#typesafe-system-one) | TypeSafe System One evaluations |
| `GET /v1/models` | The model catalog; no key needed |

For these endpoints, use a model that lists the endpoint in `GET /v1/models`, as shown below.

## Find a model for an endpoint [#find-a-model-for-an-endpoint]

Look model IDs up instead of hard-coding them; the catalog changes often. Each entry in `GET /v1/models` lists the endpoints that model accepts in `protocols`:

```bash
curl -s https://api.ohmygpt.com/v1/models \
  | jq -r '.data[] | select(.id | test("claude-haiku")) | [.id, ([.protocols[].path] | join(" "))] | @tsv'
```

```text
anthropic/claude-haiku-4-5	/v1/chat/completions /v1/responses /v1/messages /v1/models/{id}:generateContent
anthropic/claude-haiku-5-5	/v1/chat/completions /v1/responses /v1/messages /v1/models/{id}:generateContent
```

Filter by product type with `?service=`, for example `embedding`, `rerank`, `image`, `tts`, `stt`, `moderation`, or `ocr`:

```bash
curl -s "https://api.ohmygpt.com/v1/models?service=embedding" | jq -r '.data[].id'
```

Prices for every model are on [Models](https://www.ohmygpt.com/models).

## The charge on every response [#the-charge-on-every-response]

Every response tells you exactly what the request cost:

| Header | Value |
|---|---|
| `X-Cost-Credits` | The charge in Credits (1 USD = 250,000 Credits). Streams carry it in the stream itself; see [Streaming](/docs/api/streaming#cost-of-a-stream). |
| `X-Request-ID` | The request's ID. Use it to look the request up later, or include it when you contact support. |

Your full history is in [Usage](https://www.ohmygpt.com/usage).

<Cards>
  <Card title="Protocols" href="/docs/api/protocols" description="One model, four protocols: what you send and what you get back" />
  <Card title="Streaming" href="/docs/api/streaming" description="Events per protocol, with usage and cost at the end" />
  <Card title="Parameters" href="/docs/api/parameters" description="How sampling and output parameters apply to each model family" />
  <Card title="Thinking" href="/docs/api/thinking" description="Reasoning controls for Claude, Gemini, and GPT models" />
</Cards>
