OpenCode

Configure OpenCode to use BullSequana AI from terminal-first development workflows.

Agentic Friendly

OpenCode connects to BullSequana AI through the BSQAI API.

The BSQAI API sends each request to the server that runs the model, so the stable BullSequana API endpoint is the recommended developer integration path.

What to use

Use:

  • API type: OpenAI (Responses API)
  • base URL: https://api.<platform-domain>/v1
  • token: JWT or sk-bsq-... API key

Do not configure OpenCode against an internal model endpoint, such as KServe's.

1. Install OpenCode

Install OpenCode using your preferred installation method.

Examples:

npm install -g opencode-ai
curl -fsSL https://opencode.ai/install | bash

2. Prepare authentication

Use either:

  • a JWT bearer token
  • a BullSequana AI API key

For most persistent local tool configurations, API keys are usually more practical. Give the key chat.message.create to generate answers and tenant.read to list models in step 5. If you belong to a group in the tenant, also choose the Team the key's usage counts for. It cannot be changed later, and that team's monthly BCU cap applies to the key. See Create and use an API key.

The configuration below reads the key from the environment rather than storing it, so export it first:

export BSQ_API_KEY="sk-bsq-v1-..."

OpenCode sends the key as Authorization: Bearer, which the BSQAI API accepts.

3. Configure the provider

Create or edit ~/.config/opencode/opencode.json.

Example configuration:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "bsqai/<model-name-from-/v1/models>",
  "provider": {
    "bsqai": {
      "name": "BullSequana AI",
      "npm": "@ai-sdk/openai",
      "options": {
        "baseURL": "https://api.<platform-domain>/v1",
        "apiKey": "{env:BSQ_API_KEY}"
      },
      "models": {
        "<model-name-from-/v1/models>": {
          "name": "<model-name-from-/v1/models>",
          "limit": { "context": <context-window>, "output": <max-output-tokens> }
        }
      }
    }
  }
}

The "npm": "@ai-sdk/openai" line makes OpenCode use the official OpenAI SDK provider, which talks to the platform's /v1/responses endpoint (the Responses API). Without it, OpenCode uses a generic OpenAI-compatible provider that calls /v1/chat/completions. The BSQAI API serves both.

The limit block gives OpenCode the model's context window and maximum output tokens, which it cannot read from the API. OpenCode measures the session against context and compacts the conversation before it reaches it. Without the block, the context indicator stays at 0% and a long session fails once it reaches the model's limit. Use the values the deployment was started with; the Portal fills them in when the model publishes them.

4. Run OpenCode

Example:

opencode

The model field above makes this the default. To run one session against a different model, name it as provider/model:

opencode --model bsqai/<model-name-from-/v1/models>

5. Check model availability first

Available models are also visible in the Portal.

If you want the API-level source of truth for the current environment, use:

curl "https://api.<platform-domain>/v1/models" \
  -H "Authorization: Bearer <your-token>"

This gives OpenCode users:

  • a stable API contract
  • consistent authentication
  • environment portability across clusters
  • less coupling to internal platform implementation details

The Portal generates this whole configuration with the model id and base URL already filled in. See Studio — Use model.

On this page