API Stock

运维

Generate images in Claude Code with API Stock

Add API Stock media tools to Claude Code, check access and create a landing-page illustration with a request spending ceiling.

阅读约 2 分钟5 个章节

Claude Code

claude mcp add --transport http api-stock https://api.api-stock.com/mcp

在终端中运行此命令,然后在 Claude Code 中输入 /mcp 并登录。

Give Claude Code a page-building task that includes an original image. API Stock's MCP server lets it inspect models, quote a generation and retrieve the finished media. Claude Code keeps using your selected coding model.

Connect the media tools

Run the command above from the project where you want the connection. Inside Claude Code, open /mcp, select api-stock and authenticate. Sign in to API Stock in the browser and review the requested permissions. The connection uses OAuth; keep account credentials out of project files.

You can alternatively install the existing Claude Code plugin:

text
/plugin marketplace add APIStock/api-stock-mcp
/plugin install api-stock@api-stock

Use either setup method. Adding both creates duplicate connections.

Check access without generating media

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

Discovery can list tool schemas before sign-in. Actual tool calls need authentication. Seeing the server name in /mcp does not prove that generation permissions or sufficient balance are available.

Create a hero image and use it in a page

Copy the landing-page brief. The workflow inspects a model, quotes the exact input, waits for spending approval and retrieves the finished task. Claude Code then uses its local file tools to place the image in the project.

Use the approved quote as maxCostUsd. Generate an idempotencyKey once for this logical task and reuse it if the connection drops after submission. A new key may create another billable task. Stopping Claude Code does not cancel an accepted generation.

For a reference image, call create_upload_url, upload the file with HTTP PUT and use the returned publicUrl in the model input. The upload and download require HTTP-capable local tools; MCP alone does not write your project files.

Review the result

Require a finished task, an actual local image and an evidence record with the model and task id. Inspect the page before publishing it. A request quote is an estimate; report a charged amount only when it was observed.

Revoke the connection in Dashboard → Connectors. For a second task, try the app asset brief or inspect video models.

Troubleshooting

SymptomNext step
Tools are missingCheck /mcp, authenticate and start a new session.
A tool returns unauthorizedRepeat browser sign-in and review consent.
Creation is refusedCheck balance, generation permission, model input and the spending ceiling.
A task is still processingKeep its id and poll it; avoid creating a replacement task.

Setup follows Claude Code's MCP documentation. Protocol checks and connection setup are separate from a paid end-to-end generation. The MCP reference describes each tool and its permissions.

用你自己的密钥跑一遍

在 API Stock 目录中选择模型、查看价格,再通过浏览器或 API 试用。

继续阅读