# MCP server and A2A agent

> Connect Claude Code, OpenCode or any MCP client to OpenCheese with your account, and see each tool's arguments and the JSON it returns.
>
> Web page: https://opencheese.dev/en/docs/mcp/ · Every docs page: https://opencheese.dev/llms.txt

OpenCheese is also an MCP server and an A2A agent. With your account, a client that speaks the
Model Context Protocol (MCP) or Agent2Agent (A2A) can search these docs, read the price list, list
your models, show what your key can still spend, read your notifications, ask a model and generate
images. Every call to a model is billed to your account like the same API request. An MCP client
can also make your ads and pay for them: see [Ads](#ads).

## Connect an MCP client

The server is one Streamable HTTP endpoint, `https://opencheese.dev/mcp`. In Claude Code:

```bash
claude mcp add --transport http opencheese https://opencheese.dev/mcp
```

In OpenCode:

```bash
opencode mcp add opencheese --global --url https://opencheese.dev/mcp
```

Most other clients take the same address in their MCP settings file, under a name of your choice:

```json
{
  "mcpServers": {
    "opencheese": {
      "url": "https://opencheese.dev/mcp"
    }
  }
}
```

The file and the name of its top-level key differ from client to client; the address is the same.

## Sign in

Every request needs your account, so your client asks you to sign in as soon as you add the server:

- **Claude Code:** run `/mcp`, choose `opencheese` and **Authenticate**.
- **OpenCode:** run `/mcps`, choose `opencheese` and sign in.
- **Other clients:** use the sign-in their MCP settings offer for the server.

Your browser opens OpenCheese. Sign in, check the app's name and where your answer goes, set an
optional **Spending cap**, and choose **Allow**. The app gets an API key of your account, named
after it on the **API keys** page; disable or delete that key there to sign the app out. A key
made this way never uses free models.

A client that cannot sign in can send an API key with every request instead, as
`Authorization: Bearer YOUR_OPENCHEESE_API_KEY`. In Claude Code:

```bash
claude mcp add --transport http opencheese https://opencheese.dev/mcp --header 'Authorization: Bearer YOUR_OPENCHEESE_API_KEY'
```

Without either, the server answers every request with `401` and a `WWW-Authenticate` header that
tells the client where to sign in.

## Tools

| Tool | What it does |
| --- | --- |
| `search_docs` | Finds the docs sections that match your words. |
| `list_docs_pages` | Lists the docs pages in English, Russian or German. |
| `read_docs_page` | Returns one docs page as Markdown. |
| `get_model_prices` | Returns the current price list as Markdown. |
| `list_models` | Lists the models your key can use, with your prices (per million tokens, or per image at each resolution for a model priced per image), their limits and each image model's options. |
| `get_balance` | Shows the key's spending cap, your plan's limits and your balance. |
| `get_notifications` | Returns your newest notifications, and an upcoming deployment. |
| `ask_model` | Asks a model one question and returns its answer. Billed. |
| `generate_image` | Generates images with an image model and returns them. Billed. |
| `edit_image` | Edits up to five images with an image model and returns the results. Billed. |
| `get_ad_rules` | Shows what an ad may be, what it costs and which places are free. |
| `create_ad` | Makes a draft ad with its pictures, and returns its price. |
| `update_ad` | Changes a draft ad. |
| `delete_ad` | Deletes a draft ad. |
| `list_ads` | Lists your ads with their status, money and clicks. |
| `get_ad` | Shows one ad with its clicks and payments. |
| `submit_ad` | Pays for an ad from your balance and sends it to verification. Charged. |
| `cancel_ad` | Cancels an ad waiting for verification, or ends a live one, with a refund. |

Each tool's arguments and an example of what it returns are in the [tool reference](#tool-reference)
below.

## What a tool returns

A tool answers with a list of `content` parts, as MCP carries them:

- A tool that returns data sends it as one text part of compact JSON, and the same object as
  `structuredContent` for clients that read it. The examples in the reference show that object.
- `read_docs_page` and `get_model_prices` return Markdown text.
- `generate_image` and `edit_image` return the images first, then a line of text.
- A refusal, such as a bad argument, a low balance or a model your key cannot use, has
  `isError: true` and one sentence that says what went wrong and what to do.
- While an update is announced, every result ends with one more text part that starts with ⚠️.

The whole result of a `get_notifications` call, and of the same call made again too soon:

```json
{
  "content": [{ "type": "text", "text": "{\"notifications\":[],\"deployment\":null}" }],
  "structuredContent": { "notifications": [], "deployment": null }
}
```

```json
{
  "content": [{ "type": "text", "text": "🧀 Check notifications at most once every 5 seconds. Try again in 3 seconds." }],
  "isError": true
}
```

An argument a tool does not list is refused, so a misspelled name never goes unnoticed.

## Ads

Your agent can make an ad that shows beside the OpenCheese app or on its home page, and pay for it
from your balance. Ask it, for example, for "a pay-per-click ad for https://example.com in the app,
in English and German, with 10 credits of extra budget for two days". It then:

1. reads the sizes, prices and free places with `get_ad_rules`;
2. makes the draft with `create_ad`, with a picture per language, and shows you its price;
3. pays for it with `submit_ad`, naming that price.

A picture is a JPEG or GIF exactly 175 px wide and 175 to 250 px tall, up to 500 KB, with its
text in its own language. It is never scaled or converted, so give your agent pictures of that size;
an image from `generate_image` is too large to use as it is.

An administrator checks every ad before it shows, and approves it or declines it with a full
refund. The charge comes from your balance and counts toward the key's spending cap when it has
one, so the cap you set at sign-in also limits what an agent spends on ads. `create_ad` gives a
link that opens the draft in **My Ads**, to preview it beside the app or send it yourself. The
[Ads API](https://opencheese.dev/en/docs/ads.md) has every rule and field.

## Tool reference

### `search_docs`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `query` | `string` | Yes | The words to look for, 2 to 200 characters, such as `Retry-After`. |

It searches the English docs and returns up to five sections, best match first:

```json
{
  "query": "Retry-After",
  "results": [
    {
      "title": "Errors and rate limits",
      "url": "https://opencheese.dev/en/docs/errors/",
      "markdownUrl": "https://opencheese.dev/en/docs/errors.md",
      "excerpt": "Errors worth waiting for add `retry_after` (seconds) to the body and a `Retry-After` header."
    }
  ]
}
```

`url` is the page, `markdownUrl` the same page as Markdown, and `excerpt` the first line of the
section that names one of your words. `results` is empty when no section does.

### `list_docs_pages`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `language` | `string` | No | `en` (the default), `ru` or `de`. |

```json
{
  "language": "en",
  "pages": [
    {
      "page": "quickstart",
      "title": "API quickstart",
      "summary": "Connect to the OpenCheese AI gateway: API host and base URLs, Bearer and x-api-key auth, a first curl request, and every docs page for the API and your tools.",
      "markdownUrl": "https://opencheese.dev/en/docs.md"
    },
    {
      "page": "sessions",
      "title": "Sessions",
      "summary": "One conversation, one session: the opencheese-session-uuid header.",
      "markdownUrl": "https://opencheese.dev/en/docs/sessions.md"
    }
  ]
}
```

`page` is the id `read_docs_page` takes. The quickstart comes first, then every other page.

### `read_docs_page`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `page` | `string` | Yes | `quickstart`, or a `page` from `list_docs_pages`, such as `claude-code`. |
| `language` | `string` | No | `en` (the default), `ru` or `de`. |

It returns the page as Markdown text, the same as the page's `.md` address, not JSON. An unknown
page is an error that points to `list_docs_pages`.

### `get_model_prices`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `language` | `string` | No | `en` (the default), `ru` or `de`. |

It returns the public price list as Markdown text, as the **Prices** page shows it: every model's
price per million tokens or per image, list prices, discounts and free models. For the models your
key can use, at your prices and as JSON, call `list_models`.

### `list_models`

It takes no arguments. Two models of the list (the values are examples):

```json
{
  "models": [
    {
      "id": "MODEL_ID",
      "name": "Example Model",
      "input": ["text", "image"],
      "output": ["text"],
      "pricing": { "per_million_tokens": { "input": 0.5, "output": 2, "cache_read": 0.05, "cache_write": 0.6 } },
      "reasoning_levels": ["max", "medium", "low"],
      "context_window": 1000000,
      "max_output_tokens": 131000
    },
    {
      "id": "IMAGE_MODEL_ID",
      "name": "Example Image Model",
      "input": ["text", "image"],
      "output": ["image"],
      "pricing": {
        "per_image": [
          { "resolution": "1K", "price": 0.04, "source_image": 0.002 },
          { "resolution": "2K", "price": 0.08, "source_image": 0.002 }
        ]
      },
      "image": {
        "max_images_per_request": 4,
        "params": [
          { "id": "aspect_ratio", "values": ["1:1", "16:9", "9:16"] },
          { "id": "image_size", "values": ["1K", "2K"] },
          { "id": "output_format", "values": ["png", "jpeg"], "default": "png" },
          { "id": "negative_prompt", "max_length": 500, "note": "Added to the end of the prompt as \"Avoid: ...\": this model has no negative prompt of its own." },
          { "id": "seed", "min": 0, "max": 2147483647 }
        ]
      }
    }
  ]
}
```

| Field | Meaning |
| --- | --- |
| `id` | The `model` for `ask_model`, `generate_image` and `edit_image`. |
| `input`, `output` | What the model reads and writes: `text`, `image`. |
| `pricing` | Your price in credits (USD). `per_million_tokens` has `input`, `output` and, where the model caches, `cache_read`, `cache_write` and the longer-lived write the model prices apart: `cache_write_1h` (the one-hour write of Claude models) or `cache_write_12h` (the twelve-hour write of GPT models). A model priced per image has `per_image` instead: one row per output `resolution`, and per `quality` where the quality changes the price, with `price` for one image and `source_image` for each image an edit sends. A resolution without a row costs the nearest lower one's. |
| `reasoning_levels` | The values `ask_model` takes as `reasoning_effort`, strongest first. |
| `context_window`, `max_output_tokens` | The most tokens the model reads in one request, and the longest answer it writes. |
| `image` | Image models only. `max_images_per_request` is the largest `n`. `params` lists every option the model takes, under `generate_image`'s argument names: the `values` it accepts and its `default` where the model declares one, `min` and `max` for a number, `max_length` for text, and a `note` where the option needs one. |

A field is left out where it does not apply: a model with no reasoning levels has no
`reasoning_levels`, and a text model has no `image`.

### `get_balance`

It takes no arguments, and returns what [GET /v1/key, /v1/plan and /v1/balance](https://opencheese.dev/en/docs/account.md)
return, each answer's `data` under its own name:

```json
{
  "key": {
    "label": "Laptop",
    "limit": 50,
    "limit_usage": 12.5,
    "limit_remaining": 37.5,
    "limit_reset": null,
    "usage": 182.4,
    "created_at": "2026-09-01T10:00:00.000Z",
    "last_used_at": "2026-10-17T09:12:00.000Z"
  },
  "plan": null,
  "balance": {
    "balance": 12.34,
    "month": "2026-10",
    "monthly_usage": { "tokens": 1234567, "credits": 8.9, "requests": 312 },
    "monthly_limits": { "tokens": null, "credits": null }
  }
}
```

Every amount is in credits (USD). `limit` is the key's spending cap, `null` for none. `plan` is
`null` without a plan; with one, it has the plan's name, dates, its five-hour, weekly and monthly
windows and its balance options. [Key, plan and balance](https://opencheese.dev/en/docs/account.md) explains every field.

### `get_notifications`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `language` | `string` | No | `en` (the default), `ru` or `de`. A notification written only in other languages is left out. |
| `limit` | `integer` | No | How many of the newest to return, 1 (the default) to 10. |
| `categories` | `string[]` | No | Any of `MAINTENANCE`, `NEWS`, `EVENT` and `ADS`. Every category when left out. |

```json
{
  "notifications": [
    {
      "id": "8f6c2e1a-3b4d-4c5e-9f70-1a2b3c4d5e6f",
      "category": "MAINTENANCE",
      "title": "Maintenance on Sunday",
      "message": "The dashboard is read-only from **02:00 to 02:30 UTC**.",
      "published_at": "2026-11-05T10:00:00.000Z",
      "read": false
    }
  ],
  "deployment": null
}
```

It reads [GET /v1/notifications](https://opencheese.dev/en/docs/notifications.md), which explains every field. `message`
is Markdown, and `read` is `true` once you opened or closed the notification on the dashboard.
A key may call it once every five seconds; a faster call is an error that says how long to wait.

`deployment` is `null` until an update is about to take the API offline for a short time. About a
minute before, it says when (`starts_by`), what goes offline (`services`) and what to do
(`message`), and every tool result ends with a line that says the same, so your agent can pause
and retry once it is back.

### `ask_model`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `model` | `string` | Yes | A model `id` from `list_models`. |
| `prompt` | `string` | Yes | The question or task. |
| `system` | `string` | No | Instructions for the model. |
| `reasoning_effort` | `string` | No | One of the model's `reasoning_levels`. The model's default when left out. |

The answer comes back as text, and as this object:

```json
{
  "model": "MODEL_ID",
  "text": "An AI gateway is one API in front of many AI models.",
  "finish_reason": "stop",
  "usage": { "prompt_tokens": 24, "completion_tokens": 13, "total_tokens": 37 }
}
```

`finish_reason` is `length` when the answer was cut off at the model's longest answer, and
`usage` counts the tokens as [Chat Completions](https://opencheese.dev/en/docs/chat-completions.md) does. The call is billed
like the same request to `/v1/chat/completions`. An answer that takes a while arrives as a stream
the client keeps open.

### `generate_image`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `model` | `string` | Yes | An image model's `id` from `list_models`: one whose `output` is `image`. |
| `prompt` | `string` | Yes | What the image shows. |
| `n` | `integer` | No | How many images, up to the model's `max_images_per_request`. |
| `aspect_ratio`, `image_size`, `quality`, `background`, `output_format`, `size` | `string` | No | A value the model lists for the option in `image.params`. |
| `output_compression`, `frame_count`, `frame_duration_ms` | `integer` | No | Where the model lists them, in its range: JPEG or WebP compression (100 the least), a GIF's frame count and milliseconds per frame. |
| `negative_prompt` | `string` | No | What the image should not show. Every model takes one. |
| `seed` | `integer` | No | Where the model lists `seed`: the same seed and prompt give a similar image. |
| `prompt_extend`, `thinking` | `boolean` | No | Where the model lists them: rewrite a short prompt into a detailed one, and reason before drawing. |

An option left out has the model's default, which `image.params` shows where it is known. The
options are those of the [Image API](https://opencheese.dev/en/docs/images.md), and the call is billed like the same
request. The whole result:

```json
{
  "content": [
    { "type": "image", "data": "iVBORw0KGgoAAAANSUhEUgAA", "mimeType": "image/png" },
    { "type": "text", "text": "Generated with IMAGE_MODEL_ID for 0.04 credits (USD). Image id: img_3kV9qT7wXbN2mR5yHc8LpA (for edit_image, kept 24 hours)." }
  ],
  "structuredContent": {
    "model": "IMAGE_MODEL_ID",
    "images": [{ "id": "img_3kV9qT7wXbN2mR5yHc8LpA", "mime_type": "image/png" }],
    "cost_usd": 0.04
  }
}
```

Each image comes as base64 with its type, in the order of `images`. `cost_usd` is what the call
cost in credits (USD), `null` when the price is not known. An id is kept with your account for 24
hours, for `edit_image`; an image that could not be kept has no `id`.

### `edit_image`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `model` | `string` | Yes | An image model's `id` from `list_models`. |
| `prompt` | `string` | Yes | What to change, or how to combine the images. |
| `image_ids` | `string[]` | One of the two | Ids that `generate_image` or `edit_image` returned in the last 24 hours. |
| `images` | `string[]` | One of the two | Images of your own, as base64 or `data:` URLs: PNG, JPEG or WebP, up to 10 MB each. |
| The options of `generate_image` | | No | As for `generate_image`. |

Up to five images in all: the ones named in `image_ids` first, then your own. Your agent can keep
editing a picture by its id without sending it back. The result has the shape of
`generate_image`'s, with `Edited` in its text. Each source image is billed as the
[Image API](https://opencheese.dev/en/docs/images.md) bills an edit. The returned images are kept with your account for up
to 24 hours, then deleted; the images you send are not kept.

### `get_ad_rules`

It takes no arguments, and returns what [GET /v1/ads/rules and /v1/ads/places](https://opencheese.dev/en/docs/ads.md)
return, the places under `places`:

```json
{
  "access": { "can_create": true, "open_to_users": true },
  "kinds": ["click", "time"],
  "pages": ["landing", "app"],
  "languages": ["en", "de", "ru"],
  "positions": 4,
  "picture": { "width": 175, "min_height": 175, "max_height": 250, "formats": ["jpeg", "gif"], "max_bytes": 512000 },
  "prices": { "per_pixel": 0.01, "pages": { "landing": 1, "app": 0.5 }, "per_language": 0.1, "extra_day_per_page": 0.5, "per_minute": 0.005 },
  "limits": { "min_reward_per_click": 0.01, "max_extra_budget": 10000, "max_run_days": 3, "min_minutes": 60, "max_minutes": 43200, "drafts_per_key": 10, "pictures_per_key_per_hour": 40 },
  "landing": { "claim_days": 7, "paid_clicks_per_address_per_day": 3 },
  "places": {
    "landing": {
      "en": ["taken", "free", "free", "free"],
      "de": ["free", "free", "free", "free"],
      "ru": ["free", "free", "free", "free"]
    },
    "app": {
      "en": ["taken", "free", "free", "yours"],
      "de": ["taken", "free", "free", "free"],
      "ru": ["free", "free", "free", "free"]
    }
  }
}
```

`access.can_create` is `false` while ads are not open to your account. Amounts are credits (USD):
an ad's price is `per_pixel` for each pixel of its width plus height, each page and each language,
plus a pay-per-click ad's extra budget and extra days or a time ad's minutes. Each list in `places`
holds the four positions down the right side of one page in one language, from the top: `free`,
`taken`, or `yours` when another of your ads holds it.

### `create_ad`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `kind` | `string` | Yes | `click` for pay per click, `time` for a time ad. It cannot change later. |
| `link` | `string` | No | The `https://` address the ad leads to, wherever `links` names no other. |
| `links` | `object[]` | No | `{"page", "language", "link"}` for each page in a language that leads somewhere else, such as each language's own site; `link` `null` goes back to the ad's own. |
| `pages` | `string[]` | No | `landing` (the home page), `app` or both. The app when left out. |
| `languages` | `string[]` | No | Any of `en`, `de` and `ru`. Those of the pictures when left out. |
| `pictures` | `object[]` | No | One per language: `{"language", "image"}` with a JPEG or GIF as base64 or a `data:` URL, or `{"language", "picture_id"}` with an id from an ad's `pictures`. |
| `position` | `integer` | No | Its place down the right side, 1 (the top) to 4. 1 when left out. |
| `reward_per_click`, `extra_budget`, `run_days` | `number`, `number`, `integer` | No | Pay per click only: what one click pays, the extra click budget in whole cents, and 1 to 3 days. 0.01, 0 and 1 when left out. |
| `duration_minutes` | `integer` | No | Time ads only: 60 minutes to 30 days. 1440 when left out. |

A picture is a JPEG or GIF exactly 175 px wide and 175 to 250 px tall, up to 500 KB: a PNG, a
WebP or another size is refused, never scaled. A GIF may be animated and is kept as you sent it.
The tool uploads each picture, then makes the draft with them. Nothing is charged:

```json
{
  "ad": {
    "id": "ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10",
    "kind": "click",
    "status": "draft",
    "link": "https://example.com/",
    "links": [],
    "pages": ["app"],
    "languages": ["en", "de"],
    "pictures": [
      { "language": "en", "picture_id": "pic_5b2e9d40-7a1c-4f3e-8d26-0c9b1a7e4f53", "height": 219 },
      { "language": "de", "picture_id": "pic_e1a4c7d2-93b8-4d0f-a6e5-2b7f8c1d9e04", "height": 219 }
    ],
    "position": 2,
    "reward_per_click": 0.01,
    "extra_budget": 10,
    "run_days": 2,
    "budget_left": 0,
    "clicks_left": 0,
    "price": 15.14,
    "charged": 0,
    "refunded": 0,
    "clicks": 0,
    "minutes_left": 0,
    "decline_reason": null,
    "refused": null,
    "end_reason": null,
    "created_via": "mcp",
    "created_at": "2026-11-07T10:00:00.000Z",
    "submitted_at": null,
    "approved_at": null,
    "ended_at": null
  },
  "quote": { "total": 15.14, "picture": 3.94, "pages": 0.5, "languages": 0.2, "extra_budget": 10, "click_budget": 14.64, "run_fee": 0.5, "time": 0, "fee": 0.5, "clicks": 1464 },
  "problem": null,
  "place": { "free": true, "taken": [] },
  "dashboard_url": "https://opencheese.dev/app#ads?ad=ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10"
}
```

| Field | Meaning |
| --- | --- |
| `ad` | The ad, as `list_ads` shows it. |
| `quote` | Its price in credits (USD), part by part. `total` is what `submit_ad` charges; `click_budget` is paid out to the people who click, `clicks` rewards in all; `fee` is what OpenCheese keeps. |
| `problem` | `null`, or what still stops `submit_ad`, such as `missing_image`. |
| `place` | Whether its position is free in every page and language it books; `taken` lists where not. |
| `dashboard_url` | The ad in **My Ads**, to preview it beside the app or send it yourself. |

### `update_ad`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `ad_id` | `string` | Yes | The draft's `id`. |
| `link`, `links`, `pages`, `languages`, `pictures`, `position`, `reward_per_click`, `extra_budget`, `run_days`, `duration_minutes` | | No | As for `create_ad`. Only those you send change. |

It returns what `create_ad` returns. An ad sent to verification no longer changes here: cancel it
with `cancel_ad` for a full refund, or change it in **My Ads**.

### `delete_ad`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `ad_id` | `string` | Yes | A draft's `id`. |

```json
{ "id": "ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10", "deleted": true }
```

Only a draft is deleted: an ad sent to verification is cancelled or ended with `cancel_ad`.

### `list_ads`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `kind` | `string` | No | Only `click` or `time` ads. |
| `status` | `string[]` | No | Only ads in these statuses, such as `["waiting", "live"]`. |

Your ads, newest first:

```json
{
  "ads": [
    {
      "id": "ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10",
      "kind": "click",
      "status": "live",
      "link": "https://example.com/",
      "links": [],
      "pages": ["app"],
      "languages": ["en", "de"],
      "pictures": [
        { "language": "en", "picture_id": "pic_5b2e9d40-7a1c-4f3e-8d26-0c9b1a7e4f53", "height": 219 },
        { "language": "de", "picture_id": "pic_e1a4c7d2-93b8-4d0f-a6e5-2b7f8c1d9e04", "height": 219 }
      ],
      "position": 2,
      "reward_per_click": 0.01,
      "extra_budget": 10,
      "run_days": 2,
      "budget_left": 14.6,
      "clicks_left": 1460,
      "price": 15.14,
      "charged": 15.14,
      "refunded": 0,
      "clicks": 4,
      "minutes_left": 2815,
      "decline_reason": null,
      "refused": null,
      "end_reason": null,
      "created_via": "mcp",
      "created_at": "2026-11-07T10:00:00.000Z",
      "submitted_at": "2026-11-07T10:02:00.000Z",
      "approved_at": "2026-11-07T10:30:00.000Z",
      "ended_at": null
    }
  ]
}
```

| Field | Meaning |
| --- | --- |
| `status` | `draft`, `checking` (its charge being confirmed), `waiting` (paid, for an administrator), `live`, `stopped` (paused by an administrator), `ended`, `cancelled`, `declined` (with `decline_reason`, refunded in full) or `deleted`. |
| `link`, `links` | Where it leads: `link`, except the pages in a language that `links` sends somewhere else. |
| `price`, `charged`, `refunded` | In credits (USD): the price as set, and what was charged and refunded so far. |
| `reward_per_click`, `extra_budget`, `run_days`, `budget_left`, `clicks_left` | A pay-per-click ad's: its settings, and the click budget and rewards still to pay out. A time ad has `duration_minutes` instead. |
| `clicks`, `minutes_left` | The recorded clicks, and the run time left while it is live or stopped. |
| `refused` | `null`, or `{"amount", "reason", "at"}` for a payment that was refused: `reason` is `balance`, `key_cap` (more than the key may still spend) or `key_inactive`. |
| `created_via` | Where it was made: `dashboard`, `api` or `mcp`. |

### `get_ad`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `ad_id` | `string` | Yes | The ad's `id`. |

What `create_ad` returns for the ad, with its newest 50 clicks and its payments:

```json
{
  "ad": {
    "id": "ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10",
    "kind": "click",
    "status": "live",
    "link": "https://example.com/",
    "links": [],
    "pages": ["app"],
    "languages": ["en", "de"],
    "pictures": [
      { "language": "en", "picture_id": "pic_5b2e9d40-7a1c-4f3e-8d26-0c9b1a7e4f53", "height": 219 },
      { "language": "de", "picture_id": "pic_e1a4c7d2-93b8-4d0f-a6e5-2b7f8c1d9e04", "height": 219 }
    ],
    "position": 2,
    "reward_per_click": 0.01,
    "extra_budget": 10,
    "run_days": 2,
    "budget_left": 14.6,
    "clicks_left": 1460,
    "price": 15.14,
    "charged": 15.14,
    "refunded": 0,
    "clicks": 4,
    "minutes_left": 2815,
    "decline_reason": null,
    "refused": null,
    "end_reason": null,
    "created_via": "mcp",
    "created_at": "2026-11-07T10:00:00.000Z",
    "submitted_at": "2026-11-07T10:02:00.000Z",
    "approved_at": "2026-11-07T10:30:00.000Z",
    "ended_at": null
  },
  "quote": { "total": 15.14, "picture": 3.94, "pages": 0.5, "languages": 0.2, "extra_budget": 10, "click_budget": 14.64, "run_fee": 0.5, "time": 0, "fee": 0.5, "clicks": 1464 },
  "problem": null,
  "place": { "free": true, "taken": [] },
  "dashboard_url": "https://opencheese.dev/app#ads?ad=ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10",
  "clicks": [
    {
      "id": "clk_7a3e1c90-5d2b-4f8e-b6a1-9c0d2e4f6a8b",
      "who": { "kind": "user", "name": "*mnewher*", "person": 1 },
      "page": "app",
      "language": "en",
      "reward": 0.01,
      "reward_state": "paid",
      "created_at": "2026-11-07T11:20:00.000Z"
    }
  ],
  "payments": [
    {
      "id": "chg_1d4b7e2a-8c3f-4a9d-b5e6-0f2a7c9d1e3b",
      "kind": "charge",
      "reason": "submit",
      "amount": 15.14,
      "state": "applied",
      "created_at": "2026-11-07T10:02:00.000Z",
      "settled_at": "2026-11-07T10:02:00.000Z"
    }
  ]
}
```

A click's `who` names the clicker only as **My Ads** does: `user` with the name before the @
masked, `telegram`, `wallet`, `unknown` for a visitor of the home page, or `deleted`; `person`
numbers the ad's clickers. The ad's `clicks` counts every click, the list only the newest 50.

### `submit_ad`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `ad_id` | `string` | Yes | A draft's `id`. |
| `expected_total` | `number` | Yes | The `total` of its `quote` you were shown, in credits (USD). |

It takes that total from your balance and sends the ad to verification. An ad whose price differs
is refused and not charged, with its price; so are an ad past the key's spending cap, an empty
balance, a taken place and a missing picture, each with what to do.

```json
{
  "ad": {
    "id": "ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10",
    "kind": "click",
    "status": "waiting",
    "link": "https://example.com/",
    "links": [],
    "pages": ["app"],
    "languages": ["en", "de"],
    "pictures": [
      { "language": "en", "picture_id": "pic_5b2e9d40-7a1c-4f3e-8d26-0c9b1a7e4f53", "height": 219 },
      { "language": "de", "picture_id": "pic_e1a4c7d2-93b8-4d0f-a6e5-2b7f8c1d9e04", "height": 219 }
    ],
    "position": 2,
    "reward_per_click": 0.01,
    "extra_budget": 10,
    "run_days": 2,
    "budget_left": 14.64,
    "clicks_left": 1464,
    "price": 15.14,
    "charged": 15.14,
    "refunded": 0,
    "clicks": 0,
    "minutes_left": 0,
    "decline_reason": null,
    "refused": null,
    "end_reason": null,
    "created_via": "mcp",
    "created_at": "2026-11-07T10:00:00.000Z",
    "submitted_at": "2026-11-07T10:02:00.000Z",
    "approved_at": null,
    "ended_at": null
  }
}
```

`status` is `waiting` for an administrator, or `checking` while the charge is being confirmed:
`list_ads` shows the outcome a moment later. The charge counts toward the key's usage, and toward
its spending cap when it has one; a refund of the ad gives it back.

### `cancel_ad`

| Argument | Type | Required | What it is |
| --- | --- | --- | --- |
| `ad_id` | `string` | Yes | The `id` of an ad waiting for verification, live or stopped. |

It cancels an ad waiting for verification and refunds all it cost, or ends a live or stopped ad
early and refunds the click budget nobody earned and the run time not used:

```json
{
  "ad": {
    "id": "ad_8c1f2d6e-0b4a-4e7c-9a51-2f6d3c8b7e10",
    "kind": "click",
    "status": "ended",
    "link": "https://example.com/",
    "links": [],
    "pages": ["app"],
    "languages": ["en", "de"],
    "pictures": [
      { "language": "en", "picture_id": "pic_5b2e9d40-7a1c-4f3e-8d26-0c9b1a7e4f53", "height": 219 },
      { "language": "de", "picture_id": "pic_e1a4c7d2-93b8-4d0f-a6e5-2b7f8c1d9e04", "height": 219 }
    ],
    "position": 2,
    "reward_per_click": 0.01,
    "extra_budget": 10,
    "run_days": 2,
    "budget_left": 0,
    "clicks_left": 0,
    "price": 15.14,
    "charged": 15.14,
    "refunded": 15.1,
    "clicks": 4,
    "minutes_left": 0,
    "decline_reason": null,
    "refused": null,
    "end_reason": "owner",
    "created_via": "mcp",
    "created_at": "2026-11-07T10:00:00.000Z",
    "submitted_at": "2026-11-07T10:02:00.000Z",
    "approved_at": "2026-11-07T10:30:00.000Z",
    "ended_at": "2026-11-07T11:35:00.000Z"
  },
  "refund": 15.1
}
```

`refund` is what goes back to your balance, in credits (USD). A draft is deleted with `delete_ad`
instead.

## A2A agent

The agent's card is at `https://opencheese.dev/.well-known/agent-card.json` and its endpoint is
`https://opencheese.dev/a2a` (A2A 1.0, JSON-RPC). Send the `A2A-Version: 1.0` header, your API key
or the key a sign-in gave the client as a Bearer token, and name the model in the message's
metadata:

```bash
curl https://opencheese.dev/a2a \
  -H "Authorization: Bearer $OPENCHEESE_API_KEY" \
  -H "A2A-Version: 1.0" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "SendMessage", "params": {"message": {"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "What is an AI gateway?"}], "metadata": {"model": "MODEL_ID"}}}}'
```

The answer is a message with the model's text. There are two skills: `ask-model`, the default,
and `generate-image`, chosen with `"skill": "generate-image"` in the same metadata, which answers
with the images and takes the Image API's options there too, such as `n` or `aspect_ratio`. It
edits instead when the message carries images, as `raw` file parts or as ids in `"image_ids"`, and
every reply names its images' ids in `image_ids`, as the MCP tools do. A message that names no
model gets the models your key can use for that skill instead, with your prices, at no charge.
Each message is answered on its own: the agent keeps no conversations and no tasks.

## Errors

- `401` with `WWW-Authenticate`: no key was sent, or the key was refused. Sign in again or check
  the key.
- An account tool's error carries the API's own message, such as a low balance or a model your key
  cannot use; the [Errors](https://opencheese.dev/en/docs/errors.md) page lists them.
