ULK Cloud

OpenCode Custom Provider | OpenAI-Compatible Config and API Key

Add a provider under providers in opencode.jsonc with package @opencode/ai/providers/openai-compatible and settings.baseURL https://api.ulkcloud.com/v1, list glm-5.3, glm-5.3-uncensored, and deepseek-v4.1-flash under models, and save the sk-ulk- key with /connect. Keep limit.output at 32000 and point agents.title.model at deepseek-v4.1-flash.

To use an OpenAI-compatible API in OpenCode, add a custom provider under providers in opencode.jsonc with "package": "@opencode/ai/providers/openai-compatible", set settings.baseURL to the API's /v1 URL, list every model under models, and give OpenCode the API key with /connect. For ULK Cloud, the base URL is https://api.ulkcloud.com/v1, the key starts with sk-ulk-, and the models that worked with OpenCode-style tool calls are glm-5.3, glm-5.3-uncensored, and deepseek-v4.1-flash. Select one as ulkcloud/glm-5.3.

Everything below was checked on December 3, 2026, against the source code and documentation of OpenCode 2.4.4 (commit 1855aa24), the V2 release. We read the code that builds OpenCode's requests and sent requests in the same shape to the ULK Cloud API. We did not run the OpenCode app itself.

opencode.jsonc for an OpenAI-compatible custom provider

OpenCode 2.4.4 reads opencode.jsonc (or opencode.json) from ~/.config/opencode/ for every project, and from the project folder or its .opencode/ folder for one project. A custom OpenAI-compatible provider needs a provider ID, the @opencode/ai/providers/openai-compatible package, settings.baseURL, and at least one model. OpenCode does not fetch a model list from a custom provider, so a model that is not under models never appears in /models.

This is a complete configuration for ULK Cloud:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "ulkcloud/glm-5.3",
  "providers": {
    "ulkcloud": {
      "name": "ULK Cloud",
      "env": ["ULK_CLOUD_API_KEY"],
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://api.ulkcloud.com/v1"
      },
      "models": {
        "glm-5.3": {
          "name": "GLM-5.3",
          "capabilities": { "tools": true, "input": ["text"], "output": ["text"] },
          "limit": { "context": 1000000, "output": 32000 },
          "cost": { "input": 0.40, "output": 1.30 }
        },
        "glm-5.3-uncensored": {
          "name": "GLM-5.3 Uncensored",
          "capabilities": { "tools": true, "input": ["text"], "output": ["text"] },
          "limit": { "output": 32000 },
          "cost": { "input": 0.35, "output": 1.10 }
        },
        "deepseek-v4.1-flash": {
          "name": "DeepSeek V4.1 Flash",
          "capabilities": { "tools": true, "input": ["text"], "output": ["text"] },
          "limit": { "context": 1048576, "output": 32000 },
          "cost": { "input": 0.07, "output": 0.22 }
        }
      }
    }
  },
  "agents": {
    "title": { "model": "ulkcloud/deepseek-v4.1-flash" }
  }
}
KeyValueWhy
providers.ulkcloudAny IDThe part before / in model references such as ulkcloud/glm-5.3.
package@opencode/ai/providers/openai-compatibleSends Chat Completions requests to {baseURL}/chat/completions.
settings.baseURLhttps://api.ulkcloud.com/v1Include /v1.
env["ULK_CLOUD_API_KEY"]Lets OpenCode read the key from that variable (see the next section).
capabilities.input["text"]OpenCode assumes image input for models outside its catalog. ULK Cloud accepts text only.
limit.output32000Sent as max_completion_tokens. It decides how much balance each request holds.
costUSD per million tokensOnly for OpenCode's own cost display. ULK Cloud bills from its own price list.
agents.title.modelulkcloud/deepseek-v4.1-flashThe model that names sessions.

Configuration written for OpenCode 1.x uses provider (singular), npm: "@ai-sdk/openai-compatible", and options.baseURL. OpenCode 2.4.4 still reads that form and converts it in memory, but keep each provider entry entirely in one form.

Give OpenCode the ULK Cloud API key

The simplest way to give OpenCode a ULK Cloud API key is /connect. Every provider in opencode.jsonc gets a Manually enter API Key method, and OpenCode 2.4.4 saves the key in its own database (usually ~/.local/share/opencode/opencode.db), not in the config file.

  1. Create a key on the API Keys page of the ULK Cloud console. It starts with sk-ulk-.
  2. Start OpenCode and run /connect.
  3. Choose ULK Cloud, then Manually enter API Key, and paste the key.
  4. Run /models and pick a ulkcloud/... model.

From a terminal, opencode auth login opens the same provider picker.

An environment variable also works, with one catch. OpenCode 2.4.4 sends model requests from a shared background server, and env is read from that server's process, not from your shell. A variable exported in your shell reaches the server only if the server was started from that shell. Set the variable on the server instead:

opencode service set env ULK_CLOUD_API_KEY sk-ulk-...
opencode auth list

auth list shows the connection with type environment when OpenCode can see the variable. A key saved with /connect takes precedence over the environment variable.

A third option is "apiKey": "{env:ULK_CLOUD_API_KEY}" inside settings. If the variable is missing, OpenCode substitutes an empty string, and ULK Cloud answers with invalid_api_key. Do not write the key itself into a config file that you commit.

ULK Cloud models for OpenCode: IDs, prices, and limits

Three ULK Cloud models returned streamed tool calls and token usage for OpenCode-shaped requests on December 3, 2026: glm-5.3, glm-5.3-uncensored, and deepseek-v4.1-flash. Prices are per million tokens, as of December 3, 2026.

Model IDInputOutputContextMax output
glm-5.3$0.40$1.301,000,000131,072
glm-5.3-uncensored$0.35$1.10Not published131,072
deepseek-v4.1-flash$0.07$0.221,048,576393,216
  • glm-5.3-uncensored adds about 5,300 input tokens to every request, and ULK Cloud bills them as input. A coding agent sends many requests per task, so this adds about $0.002 per request.
  • For glm-5.3-uncensored, leave limit.context out. OpenCode then assumes 200,000 tokens and compacts the session before it grows past that.
  • Keep limit.output at or below the max output column. A larger value fails every request with a 400 error (see the errors section).

The current list of models and prices is on the models page.

Use a cheap model for OpenCode session titles

OpenCode names each new session with a separate request to a hidden title agent. For a custom provider, OpenCode 2.4.4 sends that request to the model you are chatting with, because its automatic "small model" choice only matches a few built-in model families. With glm-5.3-uncensored selected, every session title costs about 5,300 extra input tokens, or about $0.002.

Point the title agent at deepseek-v4.1-flash to make titles almost free:

"agents": {
  "title": { "model": "ulkcloud/deepseek-v4.1-flash" }
}

A title request is mostly input (the title instructions plus your first message) and has no tools, so the model with the lowest input price fits it best. OpenCode 1.x configuration did the same with "small_model": "ulkcloud/deepseek-v4.1-flash", which OpenCode 2.4.4 still reads as agents.title.model.

OpenCode variants and reasoning_effort on ULK Cloud

OpenCode 2.4.4 adds low, medium, and high variants to every custom OpenAI-compatible model, and choosing one (ulkcloud/glm-5.3#high) adds reasoning_effort to the request. ULK Cloud accepts reasoning_effort with any value but ignores it, because ULK Cloud sets the reasoning strength of each model itself. Before December 2, 2026, ULK Cloud rejected the field with a 400 error; that no longer happens.

The variants therefore change nothing on ULK Cloud. To hide them from the model picker, add "reasoning": { "supported": false } to the model's capabilities:

"capabilities": { "tools": true, "input": ["text"], "output": ["text"], "reasoning": { "supported": false } }

The GLM models still stream their reasoning in the reasoning_content field, and OpenCode reads that field by default.

Why OpenCode gets a 402 error while the balance is not zero

ULK Cloud holds part of the balance before each request: the cost of the input, plus max_completion_tokens times the output price. It refunds the unused part when the response ends. OpenCode sends limit.output as max_completion_tokens on every agent request, and a coding agent's input is often 50,000 to 250,000 tokens, so one request can hold several cents.

For example, a glm-5.3 request with 100,000 input tokens and limit.output at 32,000 holds about $0.04 for input and $0.04 for output. With limit.output at 131,072, the output part grows to about $0.17. When the balance cannot cover the hold, ULK Cloud answers with a 402 error even though some balance is left. OpenCode shows ULK Cloud's message, which includes the top-up link:

Your balance is too low for this request. Add credits at https://console.ulkcloud.com/billing, or set a lower max_tokens. Requests still in progress also hold part of your balance until they finish.

Keeping limit.output at 32,000 (OpenCode's own default) keeps each hold small. A long session also grows the input, so starting a new session lowers the hold too. OpenCode compacts a session automatically as it nears limit.context, which is why that value should match the model.

ULK Cloud errors you may see in OpenCode

OpenCode 2.4.4 shows the error.message text from the response. It does not retry 400, 401, 402, or 404 errors.

StatusMessage (start)Fix
401Incorrect API key provided.Run /connect again, or check that the background server sees ULK_CLOUD_API_KEY.
402Your balance is too low for this request.Add credits, or lower limit.output.
400max_completion_tokens is too large: 200000. This model supports at most 131072.Lower limit.output for that model.
400Invalid value for 'messages.0.content': Invalid inputAn image was attached. Set capabilities.input to ["text"].
400Your request appears to contain a secretULK Cloud found an API key or private key in the input. See below.
400Unsupported parameter: 'prompt_cache_key'.Remove compatibility.supportsPromptCacheKey: true.
404The model '...' does not exist.The key under models must be a ULK Cloud model ID, or set modelID to one.

ULK Cloud stops requests whose input contains an API key or private key, before they reach a model and without charging. A coding agent reads files such as .env, so this error is more likely in OpenCode than in a chat app. The safest fix is to keep secrets out of what the agent reads. If you accept sending them, add the header that turns the check off to the provider:

"headers": { "X-ULK-Allow-Secrets": "true" }

Each API key can send up to 1,000 requests per minute.

FAQ

Why is my OpenCode custom provider not showing in /models?

OpenCode does not discover models from a custom OpenAI-compatible provider. Each model must be listed under the provider's models in opencode.jsonc, and the model must not have "disabled": true.

Why does my OpenCode custom provider API key not work?

If the key is set as an environment variable, OpenCode 2.4.4 reads it on its background server, not in your shell. Run opencode service set env ULK_CLOUD_API_KEY sk-ulk-..., or save the key with /connect, which takes precedence over the variable.

Does the OpenCode reasoning effort setting work with ULK Cloud?

No. OpenCode sends reasoning_effort when a low, medium, or high variant is selected, and ULK Cloud accepts the request but ignores the field. The reasoning strength of each ULK Cloud model is fixed.

Can I keep using an OpenCode 1.x config with provider and npm?

Yes. OpenCode 2.4.4 converts provider, npm: "@ai-sdk/openai-compatible", options.baseURL, and small_model in memory without rewriting the file. Write new entries under providers with package and settings instead.

Which ULK Cloud model is cheapest for OpenCode?

deepseek-v4.1-flash, at $0.07 per million input tokens and $0.22 per million output tokens as of December 3, 2026. A coding agent's cost is mostly input, so the input price matters most.