Integrate with AI
Give a complete HopBase integration contract to a coding agent for implementation and verification.
Give the contract below to Codex, Claude Code, Cursor, or another coding agent. It tells the agent to inspect the existing stack, make the smallest required changes, discover available models, and run a real smoke test.
Set the key on your machine first
Set the HOPBASE_API_KEY environment variable locally. Never paste a real key into an AI conversation or place it in source code, commits, screenshots, or logs. If the variable is missing, the agent must stop and ask you to set it locally.
Integrate HopBase into the current project and follow this integration contract.Goals- Preserve the existing framework, SDKs, and code style. Make only the changes required for the integration.- Determine whether this is a direct end-user integration, an internal service call, or an application calling on behalf of downstream customers or tenants before choosing the architecture.- Run a real smoke test after configuration and report the changed files, selected model, HTTP status, and a short response summary.Connection settings- OpenAI-compatible Base URL: https://api.hop-base.com/v1- Anthropic-compatible Base URL: https://api.hop-base.com- API key: read only from the local HOPBASE_API_KEY environment variable or the project's existing secret manager. If it is unavailable, stop and ask me to set it locally. Never ask me to paste the real key into the conversation.- OpenAI-compatible authentication: Authorization: Bearer $HOPBASE_API_KEY- Anthropic-compatible authentication: use the Anthropic SDK api_key option or x-api-key: $HOPBASE_API_KEY. The gateway also accepts Bearer, but preserve the SDK-native method where possible.- Model discovery: GET https://api.hop-base.com/v1/models- Codex / Responses: POST https://api.hop-base.com/v1/responses- Chat: POST https://api.hop-base.com/v1/chat/completions- Gemini Omni multimodal and video: POST https://api.hop-base.com/v1/interactions- Image generation: POST https://api.hop-base.com/v1/images/generations- Image editing: POST https://api.hop-base.com/v1/images/edits- Seedance video submission: POST https://api.hop-base.com/v1/video/generate- Seedance video status: GET https://api.hop-base.com/v1/video/tasks/{task_id}Protocol selection- Claude and Claude Code: use the Anthropic protocol. The Base URL does not include /v1.- Codex CLI: use the OpenAI Responses API. The Base URL includes /v1 and wire_api = "responses".- Regular GPT applications, GLM, and Gemini chat: use OpenAI Chat Completions. The Base URL includes /v1.- Gemini Omni: gemini-omni-flash-preview uses POST /v1/interactions for text, image, and video input plus video output. Input video is limited to 10 seconds. Output is 3-10 seconds at 720p and 24 FPS. Do not parse its video result as a Chat Completions text response.- GPT Image and Gemini Banana: use the OpenAI Images-compatible API. Choose generation or editing based on current route capabilities. Do not send a Gemini generateContent payload to the image endpoints.- Seedream 5.0 Pro: supports synchronous text-to-image, one or multiple reference images, and image editing. Prefer POST /v1/images/generations with image for editing. Existing OpenAI edit code can use POST /v1/images/edits.- Seedance: use the asynchronous HopBase video task API, then poll task_id. Do not parse it as Chat Completions.Key and model rules- Each key belongs to one plan group. Never assume a key can call across Claude, OpenAI, Gemini, and Seedream groups.- Before writing model configuration, call GET /v1/models with that key and select only an ID present in the response.- Common Gemini default: gemini-3.5-flash.- Optional Gemini tool model: gemini-3.1-pro-preview-customtools, only when returned by /v1/models.- Gemini Omni video model: gemini-omni-flash-preview, only when returned by /v1/models.- Seedream model: seedream-5-0-pro, only when returned by /v1/models.- Seedance: use the complete dreamina-seedance-2-0-* ID returned by /v1/models.Downstream, multi-tenant, and external-call scenarios- If the project calls models for end users, tenants, or downstream customers, keep HOPBASE_API_KEY on the server. Never expose it to a browser, mobile app, or customer environment.- Reuse the project's caller authentication. If no authentication exists, explain the risk before creating an anonymous proxy endpoint.- Apply a model allowlist, request-size limit, timeout, concurrency limit, and rate limit per caller to prevent unauthorized access and uncontrolled spend.- Attribute every request to a caller or tenant and record model, status, latency, and usage. Redact logs and never record keys or full sensitive prompts.- Stream SSE end to end with intermediary buffering disabled. Preserve upstream 4xx and 5xx status codes and any error details safe to expose; do not rewrite all responses as 200.- Add this gateway layer only when the project actually has downstream, multi-tenant, or external callers. Do not add unrelated architecture to a local single-user tool.Implementation requirements1. Inspect existing dependencies and configuration. Reuse an installed OpenAI or Anthropic SDK.2. Put the Base URL, API key, and default model in environment variables or the existing secret-management mechanism. Update .env.example without placing a real key in it.3. Preserve current business behavior. Do not rewrite unrelated files or remove other provider configurations.4. Validate GET /v1/models first, then send a minimal non-streaming request. If the application uses streaming, add a streaming test afterward.5. On model_not_found, fetch /v1/models again and use a returned model instead of guessing an ID.6. Finish with copyable start and verification commands plus rollback instructions.For a connectivity-only test, have the agent discover models first and ask one returned chat model to reply with only ok. This avoids failures caused by hard-coding a model that is not included in the key's plan group.
How downstream use is handled
If the application calls HopBase on behalf of end users, tenants, or downstream customers, the contract requires server-side key isolation, caller authentication, a model allowlist, rate limits, usage attribution, unbuffered SSE, faithful upstream error statuses, and redacted logs. A local single-user integration does not get an unnecessary gateway layer.