Skip to main content
LiteLLMNEW PROVIDER / OCTOBER 2026

OpenCode Go.
Now in LiteLLM.

Your Go subscription, through one gateway. Choose a model, keep your client, and let LiteLLM handle the API format and session.

Your coding agentLiteLLMOpenCode Go

One connection to your Go models.

OpenCode Go is a hosted model service available through Go and Go Plus subscriptions. It gives you access to models from multiple providers. The OpenCode app is a coding agent that can use Go, or connect to other providers.

The new opencode_go/ provider brings Go into LiteLLM’s SDK and AI Gateway. Use your Console key and a Go model ID. LiteLLM selects the right upstream API, preserves the conversation’s session, and records estimated usage under OpenCode Go.

Model routing
Chat Completions, Responses, Messages, and Gemini formats, selected from model metadata.
Model discovery
Fetch available model IDs from Go, with support for a configured gateway endpoint.
Usage visibility
Published token and cache rates in LiteLLM’s catalog, including supported context tiers.

Choose the model. Keep your client.

ILLUSTRATED REQUEST FLOW
YOUR CLIENTChat Completions/v1/chat/completions
LITELLMopencode_go/glm-5.3-flash
OPENCODE GOChat Completions/chat/completions

The selected model determines the upstream format. Your client can also send native Responses or Anthropic Messages requests. This illustration makes no API calls.

From a Go account to a first reply.

You need an active Go or Go Plus subscription and an API key from OpenCode Console. The Console key authenticates LiteLLM to Go; signing in to the OpenCode app alone does not authenticate your gateway.

01

Install and set your keys

Run these commands in the shell that will host LiteLLM. Replace the placeholders with your Console key and a long, random gateway key.

The OpenCode key stays on the gateway. Clients use the LiteLLM key.

Terminal
pip install --upgrade 'litellm[proxy]'
export OPENCODE_API_KEY="your-opencode-api-key"
export LITELLM_MASTER_KEY="your-litellm-gateway-key"
02

Add a Go model

Save this as config.yaml. The client calls the alias go; LiteLLM calls the configured Go model. You do not need to set an upstream base URL.

For an existing gateway, add the model entry to your current configuration and keep your existing authentication settings.

config.yaml
model_list:
- model_name: go
litellm_params:
model: opencode_go/glm-5.3-flash
api_key: os.environ/OPENCODE_API_KEY

general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
Start the local gateway
litellm --config config.yaml --host 127.0.0.1 --port 4000
03

Send a request

In another terminal, set the same LITELLM_MASTER_KEY and run this request.

A successful response contains a greeting in choices[0].message.content and token counts in usage. Reuse the session ID for later turns in this conversation.

First request
curl http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H 'Content-Type: application/json' \
-H 'x-litellm-session-id: go-demo' \
-d '{
"model": "go",
"messages": [{"role": "user", "content": "Say hello."}]
}'
04

Connect the OpenCode app

With OpenCode installed, add this to your project’s opencode.json, or merge the entry into its existing provider object.

Start opencode from that project in a shell with your gateway key set. Run /models, choose Go · GLM-5.3-Flash under LiteLLM Go, and send a message.

OpenCode talks to your local LiteLLM gateway. LiteLLM sends the request to Go.

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"litellm-go": {
"npm": "@ai-sdk/openai-compatible",
"name": "LiteLLM Go",
"options": {
"baseURL": "http://localhost:4000/v1",
"apiKey": "{env:LITELLM_MASTER_KEY}"
},
"models": {
"go": {"name": "Go · GLM-5.3-Flash"}
}
}
}
}

Keep the conversation together.

Go uses a stable session ID to route a conversation efficiently and support prompt caching. Losing that ID at the gateway can cause a missing-session error.

Alongside the provider, we added automatic forwarding of a supplied session ID as x-opencode-session. This also covers existing OpenAI and Anthropic configurations that point to supported OpenCode endpoints.

YOUR REQUESTx-litellm-session-id: go-demoREQUEST TO OPENCODE GOx-opencode-session: go-demo

An explicit OpenCode session header takes precedence. LiteLLM does not invent a session ID when none is supplied.

Use litellm_session_id in the SDK or x-litellm-session-id at the gateway. Keep it stable within a conversation and use a different ID for a new conversation. Read the session fix ↗

Track usage.
Understand your allowance.

LiteLLM estimates request cost using Go’s published token rates. That gives you a consistent value for logs and gateway budgets.

Your Go subscription, remaining allowance, rolling limits, and resets stay with OpenCode. A LiteLLM cost estimate is not an extra invoice charge, and its budget counter does not mirror your plan’s remaining allowance.

LiteLLMTokens + estimated usage cost
OpenCode ConsoleSubscription + actual allowance

Rates and model availability can change. DeepSeek estimates use the published peak rate, so off-peak requests can cost less in Console. Check the current Go rate card for plan details.

Real models.
Real tool calls.

We tested all three incoming APIs against four upstream formats, including Gemini: 12 combinations returning responses and token usage.

We also ran streamed tool calls, tool-result follow-ups, and file reads in OpenCode. The screenshot shows a recorded file-read test through the gateway.

See the implementation and test evidence ↗
Recorded OpenCode test: the read tool opens proof.txt and returns OpenCode Go works through LiteLLM using the Go Messages model.
Recorded October 24, 2026. The test file contains only the sentence shown.