API Hubs

Эксплуатация

Add image and video generation to OpenCode

Configure API Hubs as a remote MCP server in OpenCode, authenticate and create media alongside your selected coding model.

2 мин чтенияразделов: 4

OpenCode

{ "$schema": "https://opencode.ai/config.json", "mcp": { "apihubs": { "type": "remote", "url": "https://api.apihubs.ru/mcp", "enabled": true } } }
opencode mcp auth apihubs
opencode mcp list

mcp.connectOpenCodeHint

Let OpenCode create an image for a page or prepare a video for a prototype. API Hubs adds MCP media tools alongside the coding model you selected. Your API Hubs balance pays for approved media requests separately.

Add the remote MCP configuration

Merge the JSON shown above into your project's opencode.json, preserving existing providers, tools and MCP entries. The mcp entry uses type: "remote" and the hosted URL; it contains no account credential.

Run opencode mcp auth apihubs and complete browser sign-in. Review the requested permissions before approving. OpenCode can attempt dynamic client registration and keeps its OAuth tokens in its own credential store. Leave OAuth enabled; an API Hubs API key is not an MCP token.

Use opencode mcp list to check server state. In the OpenCode session, make sure the server's tools are enabled for the selected agent.

Test account access

text
Use the API Hubs MCP tools to call get_account and list_models.
Show the balance and available image models. Do not create a generation.

If sign-in fails, run opencode mcp debug apihubs to inspect connectivity and OAuth discovery. Keep credential files and raw authentication logs private. A registered connection or public tool list does not prove authenticated account access.

Generate a file for your project

Start with the landing-page brief or the app asset brief. Ask OpenCode to inspect the current model schema and quote the final input before requesting your approval to spend.

Use maxCostUsd for the approved ceiling. Keep one idempotencyKey per logical generation and retain the task id when resuming. Wait for a terminal result before downloading it. Project files and HTTP downloads need the corresponding OpenCode tool permissions.

For video, inspect a video model's required duration and input media. Quote video separately from the image; one approved image does not authorize another generation. See the video guide.

Connection limits

This configuration follows OpenCode's remote MCP and OAuth contract. Local discovery checks are separate from interactive sign-in and a paid production generation. An available model name does not guarantee that its parameters match another model.

Use opencode mcp logout apihubs to remove local credentials. Revoke the client's consent in Dashboard → Connectors to disconnect its server-side access.

References: OpenCode MCP servers and the API Hubs MCP reference.

Запустите это со своим ключом

Выберите модель в каталоге API Hubs, проверьте цену и попробуйте её в браузере или через API.

Читать дальше