NNexithDocs
StatusDashboard ↗
Overview & quickstartModel catalogGuidesAPI referenceIntegrationsOAuth2 / OIDC

Using Nexith with opencode

opencode uses the standard OpenAI-compatible protocol (POST /v1/chat/completions), which is the most general path and the way most third-party tools integrate.

Configuration#

opencode declares an OpenAI-compatible backend through provider configuration:

{
  "provider": {
    "nexith": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Nexith",
      "options": {
        "baseURL": "https://gateway.nexith.ai/v1",
        "apiKey": "nx-你的key"
      },
      "models": {
        "nexith-core": { "name": "Nexith Core" }
      }
    }
  }
}

Configuration key names follow opencode's own documentation; on the Nexith side you only need baseURL with /v1 and apiKey set to your nx- key. https://api.nexith.ai/v1 also works.

Nexith-side support#

Capability Status
POST /v1/chat/completions (streaming/non-streaming) ✅
tools / tool_choice / parallel_tool_calls ✅ Forwarded verbatim
Streaming tool_calls slices (index + function.arguments deltas) ✅ Forwarded verbatim, not reordered
finish_reason: "tool_calls" ✅ Preserved
Assistant message replay (tool_calls + tool_call_id) ✅
GET /v1/models ✅
Anthropic / Responses protocols See claude-code.md / codex.md

When tools is non-empty, the gateway normalizes the upstream reasoning_effort to none (reasoning with tools slows things down and consumes the token budget); this is intentional.

Billing and long tasks#

  • 120-second limit per request (currently). If a single turn of opencode's long agent loop exceeds 120s, it is truncated — being worked on.
  • Streaming responses currently do not send stream_options.include_usage, so the upstream does not return streaming usage: billing is estimate-based, and the prompt cache discount does not apply. This matters a lot for agent loops with many repeated prefixes and is on the to-do list.
  • nexith-core requests over 32k context are automatically escalated to a stronger upstream and billed at the escalated tier.

Troubleshooting#

Streaming responses stall / no output for a long time The gateway sends no bytes during long upstream reasoning (there is currently no SSE heartbeat). On the to-do list.

Tool names or arguments missing If an upstream non-conformantly sends arguments before name, the current implementation freezes the name as empty. Standard upstreams do not have this problem.

401 The key must start with nx-. Note that the gateway accepts both Authorization: Bearer and x-api-key headers.