> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Setup Guide

> Connect AI agents to ToAPIs through MCP and generate images and videos with 200+ models.

Connect ToAPIs to the agents you already use through MCP. Sign in with your browser instead of copying an API key. The agent picks the model, reads its parameters, submits the job and brings back the result.

> [!NOTE]
>
> Choose the site that holds your account and credits. The examples below use the international endpoint. For a toapis.cn account, replace `https://api.toapis.com/mcp` with `https://api.toapis.cn/mcp` and use the toapis.cn console. Accounts and credits are separate.

| Site | MCP endpoint |
| - | - |
| International | `https://api.toapis.com/mcp` |
| Mainland China | `https://api.toapis.cn/mcp` |

## Before connecting

Use a client that supports remote MCP over Streamable HTTP. Optional ToAPIs skills help with model selection and prompts; their `npx skills add` commands require Node.js. You can skip skills installation and still use MCP.

For browser authorization, sign in to the matching ToAPIs site, check the client name, choose an API key or create a dedicated key with a spending limit, then click Allow. For header authentication, create a dedicated key under [API Tokens](https://toapis.com/dashboard/tokens) and replace `<API_KEY>` locally. Keep real keys out of chats and version control.

## Pick your client and connect in a few steps

> [accordion] Claude Code
>
> ### Claude Code
>
> Run the commands below in a terminal. The first installs optional skills; the second adds the MCP server. Then authorize in `/mcp` and check with `claude mcp list`.
>
> ```bash theme={null}
> npx skills add toapis/skills -g --agent claude-code -y
> claude mcp add --transport http --scope user toapis https://api.toapis.com/mcp --header "X-Locale: en"
> ```
>
> ### Authorize in /mcp
>
> Type /mcp in Claude Code, select toapis and sign in in the browser. If toapis is not listed, restart Claude Code first.

> [accordion] Claude
>
> ### Add it manually
>
> Open Settings, then Connectors, and add a custom connector. Name it ToAPIs, use the URL below, and leave the OAuth client ID and secret empty.
>
> ```text theme={null}
> https://api.toapis.com/mcp
> ```
>
> ### Connect and authorize
>
> Click Add, then Connect. Sign in on the ToAPIs page, choose an API key and click Allow.
>
> Claude reaches ToAPIs from Anthropic's servers, so do not pick a key with an IP allowlist. The Free plan allows one custom connector.

> [accordion] Codex
>
> ### Codex
>
> Run the commands below in a terminal. The first installs optional skills. Adding the server may open browser authorization automatically; finish it before continuing. If `codex mcp list` shows `Not logged in`, run `codex mcp login toapis`, finish authorization, and check again. Start a new chat after setup.
>
> ```bash theme={null}
> npx skills add toapis/skills -g --agent codex -y
> codex mcp add toapis --url https://api.toapis.com/mcp
> codex mcp list
> ```
>
> ### Authorize in the browser
>
> Codex opens the ToAPIs authorization page. Sign in, check the client name, choose an API key or create a dedicated one with a spending limit, and click Allow. In the desktop app you can also click Authenticate next to toapis under Settings, MCP servers.
>
> The Codex CLI and desktop app share one configuration, so one setup covers both.
>
> [Codex MCP](https://developers.openai.com/codex/mcp/)

> [accordion] Cursor
>
> ### Add ToAPIs
>
> Merge the following into `~/.cursor/mcp.json`, then connect in MCP settings.
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "toapis": {
>       "url": "https://api.toapis.com/mcp",
>       "headers": {
>         "X-Locale": "en"
>       }
>     }
>   }
> }
> ```
>
> Install the optional skills:
>
> ```bash theme={null}
> npx skills add toapis/skills -g --agent cursor -y
> ```
>
> ### Sign in
>
> In Cursor's MCP settings, click Connect next to toapis, sign in to ToAPIs in the browser, choose an API key and click Allow.

> [accordion] Devin
>
> ### Add ToAPIs
>
> Devin Desktop and Devin CLI share one configuration. Run these commands in a terminal, or ask Devin to run them:
>
> ```bash theme={null}
> devin mcp add -s user toapis https://api.toapis.com/mcp
> devin mcp login toapis
> ```
>
> ### Authorize in the browser
>
> devin mcp login toapis opens the browser: sign in to ToAPIs, choose an API key and click Allow. If you skip it, Devin asks you to sign in the first time it uses toapis.

> [accordion] Antigravity
>
> ### Add to the MCP configuration
>
> The Antigravity app, IDE and CLI share `~/.gemini/config/mcp_config.json`. Merge the configuration below and save it, then type /mcp in the CLI or reload the servers in settings.
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "toapis": {
>       "serverUrl": "https://api.toapis.com/mcp",
>       "headers": {
>         "X-Locale": "en"
>       }
>     }
>   }
> }
> ```
>
> Merge the `toapis` entry into your existing configuration; keep your other servers.
>
> ### Authorize and paste the code
>
> Open Antigravity settings with `Cmd + ,` (`Ctrl + ,` on Windows), go to Customizations and click Authenticate next to toapis. After you sign in to ToAPIs and click Allow, the page shows an authorization code. Paste it into settings and click Submit.

> [accordion] Doubao (豆包)
>
> ### Create a dedicated key
>
> This client only supports a key in a request header. Create a key in the ToAPIs console, preferably with a spending limit, and copy it. Replace `<API_KEY>` in the configuration below with this key.
>
> [Open API Tokens](https://toapis.com/dashboard/tokens)
>
> ### Create a custom plugin
>
> Open the Doubao desktop app, click "插件·技能·伙伴" (Plugins, Skills, Partners) in the left sidebar, click "+ 添加" (Add) at the top right of the "插件" (Plugins) page and choose "新建自定义插件" (New custom plugin). Enter ToAPIs as the server name, choose HTTP as the transport type and enter the URL below as the server URL.
>
> ```text theme={null}
> https://api.toapis.com/mcp
> ```
>
> ### Add the auth header and save
>
> Under "自定义 Headers" (Custom headers), click "+ 添加" (Add). Enter Authorization as the header name and the line below as the value (replace `<API_KEY>` with your key), then click "保存" (Save).
>
> ```text theme={null}
> Bearer <API_KEY>
> ```
>
> Add it in the Doubao desktop app (Windows or macOS). For enterprise accounts, whether custom plugins are allowed depends on the administrator's settings.

> [accordion] QwenWork (千问办公)
>
> ### Create a dedicated key
>
> This client only supports a key in a request header. Create a key in the ToAPIs console, preferably with a spending limit, and copy it. Replace `<API_KEY>` in the configuration below with this key.
>
> [Open API Tokens](https://toapis.com/dashboard/tokens)
>
> ### Paste the JSON configuration
>
> In QwenWork, open "扩展" (Extensions) > "连接器" (Connectors) in the left sidebar, click "+ 添加" (Add) > "粘贴 JSON 配置" (Paste JSON) at the top right, paste the configuration below (replace `<API_KEY>` with your key) and click "导入" (Import).
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "toapis": {
>       "type": "streamable-http",
>       "url": "https://api.toapis.com/mcp",
>       "headers": {
>         "Authorization": "Bearer <API_KEY>",
>         "X-Locale": "en"
>       }
>     }
>   }
> }
> ```
>
> ### Turn on the connector
>
> Connectors are off by default. Turn on toapis in the connector list, then start a new task. It does not work in existing conversations.

> [accordion] Qwen Code
>
> ### Run in a terminal
>
> The first command installs the ToAPIs skills (needs Node.js; MCP works without them). The second adds the ToAPIs MCP server:
>
> ```bash theme={null}
> npx skills add toapis/skills -g --agent qwen-code -y
> qwen mcp add --scope user --transport http toapis https://api.toapis.com/mcp --header "X-Locale: en"
> ```
>
> ### Authorize in the browser
>
> Run qwen to start Qwen Code. When it connects to ToAPIs, it opens the authorization page in your browser: sign in, choose a key and click Allow. Type /mcp in Qwen Code to check the connection and sign-in status of toapis.
>
> ### Browser sign-in not working? Use an API key
>
> Create a key under "API Tokens" in the console, replace `<API_KEY>` in the command below with it and run the command.
>
> ```bash theme={null}
> qwen mcp add --scope user --transport http toapis https://api.toapis.com/mcp --header "Authorization: Bearer <API_KEY>" --header "X-Locale: en"
> ```

> [accordion] Trae CN
>
> ### Create a dedicated key
>
> This client only supports a key in a request header. Create a key in the ToAPIs console, preferably with a spending limit, and copy it. Replace `<API_KEY>` in the configuration below with this key.
>
> [Open API Tokens](https://toapis.com/dashboard/tokens)
>
> ### Add the MCP server manually
>
> In Trae, open "设置" (Settings) > "MCP". In the "MCP Servers 管理" (MCP Servers) section, click "添加" (Add) > "手动添加" (Add manually) at the top right, paste the configuration below (replace `<API_KEY>` with your key) and click "确认" (Confirm).
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "toapis": {
>       "url": "https://api.toapis.com/mcp",
>       "headers": {
>         "Authorization": "Bearer <API_KEY>",
>         "X-Locale": "en"
>       }
>     }
>   }
> }
> ```
>
> ### Install the skills (recommended)
>
> They help the agent pick models and write prompts (needs Node.js; MCP works without them):
>
> ```bash theme={null}
> npx skills add toapis/skills -g --agent trae-cn -y
> ```

> [accordion] WorkBuddy
>
> ### Add a custom connector
>
> In WorkBuddy, open Connectors from the sidebar, click Custom connector in the top right, paste the configuration below and save.
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "toapis": {
>       "type": "http",
>       "url": "https://api.toapis.com/mcp"
>     }
>   }
> }
> ```
>
> ### Connect and authorize
>
> Click Trust and Connect, then sign in on the ToAPIs page that opens, choose an API key and click Allow.

> [accordion] Other clients
>
> ### Add a remote MCP server
>
> Add a remote MCP server (Streamable HTTP) with the URL below and choose OAuth sign-in. Leave the client ID and secret empty.
>
> ```text theme={null}
> https://api.toapis.com/mcp
> ```
>
> ### No browser sign-in?
>
> Some clients only support header authentication or cannot complete the browser sign-in. Create a dedicated API key in the console and connect with an Authorization: Bearer header.
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "toapis": {
>       "url": "https://api.toapis.com/mcp",
>       "headers": {
>         "Authorization": "Bearer <API_KEY>",
>         "X-Locale": "en"
>       }
>     }
>   }
> }
> ```

## Check the connection

Start a new chat and send the question below. If it shows your balance, the connection works (checking is free). If it asks you to sign in, fails authentication or cannot find the ToAPIs tools, go back and check the steps above.

```text theme={null}
How many ToAPIs credits do I have left, and how much did I spend today?
```

## What you can do once connected

Describe what you want in plain words. The agent picks a model, prepares the parameters from its docs, submits the job and follows it up.

### Generate images

Text to image, edits with reference images, aspect ratio and count.

```text theme={null}
Use ToAPIs to generate a 16:9 image of a lighthouse at dawn
```

### Generate videos

Text to video and image to video, with Seedance recommended by default.

```text theme={null}
Turn this product photo into a 5-second vertical promo video
```

### Use local files

Give the path of a local image. The agent uploads it and uses it as a reference.

```text theme={null}
Use ./product.png as a reference and put the product on a white background
```

The agent reads the model documentation before generating, uploads local references with `create_upload`, and follows progress with `get_generation`. While a job is running, let it finish rather than submit again. If the submission response is lost, reuse the same `client_request_id` when retrying; a new ID can create another billable job. If the state is `unknown`, check the console task list before resubmitting. Save the returned result URLs; clients may also download results locally.

## Available tools

| Tool | Purpose |
| - | - |
| `list_models` | List image and video models available to the current key, including prices and `docs_available`. |
| `get_model_docs` | Read model parameters before generation. Choose a model with `docs_available: true`. |
| `generate_image` | Generate images. Billable. |
| `generate_video` | Generate videos. Billable. |
| `get_generation` | Check an MCP generation by `client_request_id`. |
| `get_task` | Check an image or video task by `task_id`. |
| `create_upload` | Create a one-time upload URL for a local image, video or audio file. |
| `get_balance` | Check the key quota and account balance. |
| `list_tasks` | List recent tasks for the current key. |
| `get_usage` | Summarize charges for the current key over a time range (up to 31 days). Refunds are not subtracted. |

## FAQ

> [accordion] Do I need an API key?
>
> You do not copy one. When you authorize, you pick an existing key on the ToAPIs page or create a dedicated one, and the agent uses it through an access token. Clients that only support header authentication can connect with an API key instead.

> [accordion] How is it billed?
>
> The same as calling the API: model prices are deducted from the chosen key and your account credits. Listing models, checking the balance and looking up tasks are free. Only image and video generation is charged.

> [accordion] Why does Codex need Full access?
>
> Installing the skills and adding the MCP server writes to the Codex configuration on your computer, and the default permission mode stops the agent from changing files outside the workspace. You only need it for the setup and can switch back afterwards, or run the commands in a terminal yourself.

> [accordion] How do I disconnect?
>
> Disconnect it under Connected apps in the console. This revokes the authorization and disables a dedicated key created for the connection, unless another connection still uses it. Removing toapis in the client, for example with codex mcp remove toapis, only deletes the local configuration.

> [accordion] What is the difference between toapis.com and toapis.cn?
>
> The two sites have separate accounts and credits. Accounts on toapis.com use api.toapis.com/mcp, and accounts on toapis.cn use api.toapis.cn/mcp. Signing in on the other site shows a site mismatch.

> [accordion] Which clients are supported?
>
> Most desktop and command-line clients that support remote MCP with OAuth can connect as described under Other clients. If a client's sign-in fails, connect it with an API key instead. We will keep adding steps for more clients.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.