{
  "id": 13022935,
  "title": "OpenCode and Kilo Code With Any OpenAI-Compatible Provider: Config Files That Work, and the Context Limit Trap",
  "url": "https://urgent.news/2026/10/09/opencode-and-kilo-code-with-any-openai-compatible-provider-config",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-09T04:02:40.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/amankumar_apiclaw/opencode-and-kilo-code-with-any-openai-compatible-provider-config-files-that-work-and-the-context-4l1g"
  },
  "original_language": "en",
  "account": "OpenCode and Kilo Code enable the use of custom OpenAI-compatible providers by allowing users to configure their own provider settings. The common mistakes involve missing or incorrect details such as the limit block, base URL, model ID, and environment variable. The limit block is crucial as it defines the context window and max output tokens for the model. Without it, long sessions will fail due to the \"context limit trap\". The base URL should end with /v1, and the key should be stored in an environment variable and referenced as {env:NAME}. The model ID must match the exact ID returned from GET /v1/models. If these details are incorrect, the system will return an invalid API key (401) or model not found (404) error. Additionally, forgetting to set the limit block in the configuration will result in the client not knowing the context window, causing compaction issues in Kilo Code, and eventually leading to the provider rejecting requests due to being too long.",
  "summary": "OpenCode and Kilo Code both let you add your own OpenAI-compatible provider, and both configs look simple. The part that bit me wasn't the URL or the key. It was a missing limit block that made long sessions fall over an hour in, with no obvious cause. Here are the configs I use and the mistakes I made getting there. My examples point at APIClaw , an OpenAI-compatible gateway I build, so weigh…",
  "key_points": [
    "OpenCode and Kilo Code support custom OpenAI-compatible providers",
    "Missing or incorrect details cause context limit trap",
    "Base URL must end with /v1, key in environment variable"
  ],
  "editors_take": "Allowing custom OpenAI-compatible providers with OpenCode and Kilo Code shifts control to users but requires precise configuration to avoid errors and context limits that can halt long sessions.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}