Integrate with AI
Choose a HopBase model family and give its focused integration contract to a coding agent.
Choose the model family first, then give the contract in the active tab to Codex, Claude Code, Cursor, or another coding agent. Each contract includes only the key, protocol, and endpoints required for that family.
Choose the matching model tab
| Capability | Tab | Plan key |
|---|---|---|
| Claude API or Claude Code | Claude | Claude group key |
| GPT chat or Codex Responses | GPT / Codex | A key with the Codex Plus, Codex Pro, or GPT Official Direct (Azure) group — the Codex groups are chat only; the Azure group also serves gpt-image-2.5-flare and gpt-image-2.5-sunburst images |
| GPT Image generation | GPT / Codex | GPT Image group key — every gpt-image-* model; GPT Official Direct (Azure) also serves gpt-image-2.5-flare and gpt-image-2.5-sunburst |
| Gemini chat or Banana images | Gemini | Gemini group key |
| GLM chat or GLM through CC Switch | GLM | GLM group key |
| Seedream image generation or editing | Seedream | Seedream group key |
| Seedance video generation | Seedance | Seedance group key |
| MiniMax H3 video generation | MiniMax H3 | MiniMax H3 group key — H3 and H3-Max are two separate groups, so an H3 key does not reach H3-Max |
| Kling video, image, motion control, avatar, or lip sync | Kling | Kling group key |
| Wan 3.0 or HappyHorse video generation | Wan / HappyHorse | Wan 3.0 group key or HappyHorse group key — two separate groups in the console; one key can include both |
| Grok chat, image, or video generation | Grok | Grok group key; video uses the separate Grok video group |
| Qwen chat, with image or video input | Qwen | Qwen group key |
| DeepSeek V4 chat or reasoning | DeepSeek V4 | DeepSeek group key |
| Kimi K3 chat | Kimi K3 | Kimi K3 group key |
| Doubao Seed chat, with optional image input | Doubao Seed | Doubao Seed group key |
| Midjourney image generation | Midjourney | Midjourney Image Generation group key |
| Speech synthesis or voice cloning | MiniMax Speech | MiniMax Speech group key |
| Doubao speech synthesis, scene audio generation, or voice cloning | Doubao Speech | Doubao Speech group key |
In a multi-model project, use the dedicated variable named in the active contract, such as HOPBASE_CLAUDE_API_KEY or HOPBASE_GEMINI_API_KEY. A single-model project may keep using HOPBASE_API_KEY. Never paste a real key into an AI conversation or place it in source code, commits, screenshots, or logs.
For the exact group name behind each row, see Quickstart: Which group to choose. The Claude Max (ccmax) group works only inside the Claude Code client; for an SDK or API project, pick another Claude group.
Integrate only Claude models through HopBase in the current project. Follow this contract exactly; where it differs from the vendor's own API docs, this contract wins.
Scope
- Implement only the Claude API (Anthropic Messages) or Claude Code. Do not add, configure, or test any other model family.
- Keep the existing framework, SDKs, and code style; make the smallest change that works.
- First decide whether this is a local single-user tool, an internal service, or an application serving downstream customers or tenants; that decides key placement and architecture.
Key
- Use only a Claude-family key. Each key is bound to one console group and reaches only that group's models:
- SDK, HTTP, editors, and Claude Code: "Claude Max (Official, Full Quota)" or "Claude Max (Official, Full Quota) - Limited-Time Offer".
- "Claude Max (ccmax)" works only inside the Claude Code client; SDK or HTTP calls with that key fail.
- In a multi-model project read HOPBASE_CLAUDE_API_KEY or the existing secret manager; reuse HOPBASE_API_KEY only in an explicitly single-model project.
- Never create a key, read another family's key, or ask me to paste a real key into the conversation. If the key is missing, stop and ask me to create a key for the right group under API Keys in the console and configure it locally or in the secret manager.
Models
- First call GET https://api.hop-base.com/v1/models with this key and use only IDs beginning with claude- from the response, copied verbatim.
- On sale: claude-fable-5-1, claude-sonnet-5, claude-sonnet-5-5, claude-opus-5-5, claude-fable-5, claude-opus-5, claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5-20251001.
- 404 model_not_found means the ID is not in this key's group: fetch /v1/models again and use a returned ID. Never guess, shorten, or rewrite a model name.
Connection
- Base URL https://api.hop-base.com without /v1 (the SDK appends /v1/messages). A Base URL ending in /v1 produces /v1/v1/messages and a 404.
- Auth: the SDK api_key option, or the x-api-key header for raw HTTP. Keep SDK-native authentication.
- Endpoints: POST /v1/messages and POST /v1/messages/count_tokens. OpenAI paths (/v1/chat/completions, /v1/responses) return 404 with a Claude key; never convert Messages calls to Chat Completions.
- Claude Code: ANTHROPIC_BASE_URL=https://api.hop-base.com and ANTHROPIC_AUTH_TOKEN=<Claude key>. One-click setup writes both into the env block of ~/.claude/settings.json, which overrides shell variables.
Request rules
- Always send max_tokens. When omitted it is filled in as 4096 and long output stops with stop_reason "max_tokens".
- claude-opus-5-5: thinking is always on — thinking {"type":"disabled"} or budget_tokens returns 400; set depth with output_config.effort (default medium). tool_choice any / tool returns 400 (use auto). Assistant prefill is not supported.
- Pass earlier thinking blocks back exactly as received, signature included. Rewriting, merging, or reusing them across models returns 400 "Invalid signature in thinking block".
- Non-streaming calls are capped at 300 s (then 504). Stream long outputs and pass Anthropic SSE through unchanged; count_tokens calls also consume concurrency.
Errors and retries
- Branch on the HTTP status and error.code, never on message text. Log the x-request-id response header for support.
- Retry with backoff (2 s, 5 s, 15 s; at most 3 attempts; honor Retry-After): 429, 502, 503, 504, and interrupted streams.
- Never retry unchanged: 400, 401, 402, 403, 404, 413, 422. Fix the request, key, group, or balance first.
- Anthropic-shape errors carry no code field. Key errors (401, 402, 403) use the OpenAI shape {"error":{"code":…}} even on /v1/messages.
- 404 "This API path is not supported by the current platform" = wrong protocol or an extra /v1 in the Base URL. Fix the configuration; do not retry.
- A stream that has started fails with an event: error line while HTTP stays 200; handle it in the read loop and reissue the whole request.
Implementation
- Put the Base URL, key variable name, and default model into the existing configuration system. Update .env.example without a real key.
- Downstream or multi-tenant calls must keep the key on the server, reuse caller authentication, and add a model allowlist, request limits, timeouts, rate limiting, usage attribution, and redacted logs. A local single-user tool gets none of that extra layer.
- An account runs 5 requests at a time by default; above that the request is rejected at once with 429 and Retry-After: 1, not queued. Throttle on the client.
Validation and handoff
- Send one minimal real request after configuration. Add a streaming test only when the project actually streams.
- Send one Messages request with max_tokens 1024 asking a returned claude- model to reply "ok", and verify content[0].text.
- Report changed files, the key variable name, model ID, endpoint, HTTP status, and a redacted response summary, plus start, verification, and rollback commands.Download a rules file for your coding agent
Tick every model family this project uses. The file merges their contracts: shared rules once, then one section per family, plus links to the live docs and the MCP server. With more than three families, each section keeps the key, model, and connection rules and links to the full rules.
AGENTS.md.cursor/rules/hopbase.mdc.claude/skills/hopbase-api/SKILL.mdSwitching tabs updates both the contract and the copy action. The agent must discover models with only the selected family key and choose an ID from that response, preventing cross-plan key mistakes.
To keep the rules in the repository, tick every family the project uses in the panel under the contract and download them merged as AGENTS.md, a Cursor rule (.cursor/rules/hopbase.mdc), or a Claude Code skill (.claude/skills/hopbase-api/SKILL.md). Shared rules appear once, followed by one section per family and links to the live docs and the MCP server below. Commit the file so every agent session starts from the same rules; download it again after model or parameter changes.
How downstream use is handled
| Project context | Expected architecture |
|---|---|
| Local single-user tool | Use environment variables and the matching SDK; do not add a proxy service |
| Internal service | Keep the key server-side and preserve existing authentication, limits, and error handling |
| Customer-facing or multi-tenant service | Add key isolation, caller authentication, a model allowlist, rate limits, usage attribution, unbuffered SSE, and redacted logs |
The contract adds gateway controls only when the application acts for downstream users. It does not turn a local integration into an unnecessary service layer.
MCP server
A coding agent can also query HopBase live over MCP instead of relying on a saved file. The server is read-only and uses the same API key as your requests. Model calls still go to the regular API endpoints.
| Item | Value |
|---|---|
| Endpoint | https://api.hop-base.com/mcp (Streamable HTTP, POST only; no SSE stream or batch requests) |
| Authentication | Authorization: Bearer <key> or x-api-key: <key> |
| Scope | Results cover only the key in use: its groups, its models, and its usage |
| Tool | Returns |
|---|---|
list_models | Models this key can call, with effective prices |
get_model_limits | For one model ID: whether this key can call it, plus the endpoints, request parameters, and limits documented for it, with links to the source pages |
search_docs | The docs sections that best match a query (model ID, parameter name, error code), each with URL and snippet |
get_balance | Account balance and this key's spend-cap usage, in USD |
get_key_info | Key name, group, spend cap, concurrency cap, expiry, and status |
get_usage | Requests, tokens, and billed cost for this key; last 7 days by default, up to 92 days |
get_model_limits and search_docs read the published docs and refresh at most once an hour. The linked docs page is authoritative: a limit missing from a result does not mean there is none.
Claude Code
claude mcp add --transport http hopbase https://api.hop-base.com/mcp \
--header "Authorization: Bearer $HOPBASE_API_KEY"The shell expands the variable when you run the command, so the key is saved in your local Claude Code configuration. For a shared project configuration, add the server to .mcp.json instead and write the header as "Authorization": "Bearer ${HOPBASE_API_KEY}"; Claude Code expands it at startup, so the file holds no key.
Cursor
Add the server to .cursor/mcp.json in the project, or to ~/.cursor/mcp.json for every project:
{
"mcpServers": {
"hopbase": {
"url": "https://api.hop-base.com/mcp",
"headers": { "Authorization": "Bearer ${env:HOPBASE_API_KEY}" }
}
}
}list_models and get_model_limits see only the groups of the key you configure. To inspect another model family, add its group to the key, or register a second server entry with a key that includes it.
Next steps
- Quickstart — send a first request by hand
- Base URLs and protocols — which Base URL and protocol each model family uses
- Models — model IDs and capabilities
- Error codes and retries — what each error code means and whether to retry