Docs for OpenAI Compatible providers like Cerebras #699

Closed
opened 2026-02-16 17:27:56 -05:00 by yindo · 6 comments
Owner

Originally created by @deadcoder0904 on GitHub (Jul 14, 2025).

Originally assigned to: @jayair on GitHub.

I like how BAML does it - https://docs.boundaryml.com/ref/llm-client-providers/overview

This works for Programmatic SEO as well.

I wished the CLI had OpenAI Compatible option too or specific providers like Cerebras, Moonshot, and every new one. Kilo Code's team adds them extremely fast. That's one place to look at.

Also, search is not working well.

I did find https://opencode.ai/docs/models/ while writing this issue but took too long. I'm still confused where to put API Key for Open AI Compatible provider. Okay, I found it below baseUrl but for some reason, I can't set cerebras up.

I get this:

   █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
   █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
   ▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

┌  Add credential
│
◇  Select provider
│  Other
│
◇  Enter provider id
│  cerebras
│
▲  This only stores a credential for cerebras - you will need configure it in opencode.json, check the docs for examples.
│
◇  Enter your API key
│  ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪
│
└  Done


   █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀
   █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀
   ▀▀▀▀ █▀▀▀ ▀▀▀ ▀  ▀ ▀▀▀ ▀▀▀▀ ▀▀▀  ▀▀▀

┌  Add credential
│
■  Select provider
│  Anthropic
│

And it loops again to asking for provider. This is my config on Mac at ~/.local/share/opencode/auth.json:

{
  "$schema": "https://opencode.ai/config.json",
  "autoupdate": false,
  "model": "cerebras/qwen-3-235b-a22b",
  "provider": {
    "cerebras": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Cerebras",
      "options": {
        "baseURL": "https://api.cerebras.ai/v1",
        "apiKey": "csk-something-something"
      },
      "models": {
        "qwen-3-235b-a22b": {
          "name": "Qwen-3-235b-a22b"
        },
        "qwen-3-32b": {
          "name": "Qwen-3-32b"
        },
        "llama3.1-8b": {
          "name": "Llama3.1-8b"
        },
        "llama-3.3-70b": {
          "name": "Llama-3.3-70b"
        },
        "deepseek-r1-distill-llama-70b": {
          "name": "Deepseek-r1-distill-llama-70b"
        },
        "llama-4-scout-17b-16e-instruct": {
          "name": "Llama-4-scout-17b-16e-instruct"
        }
      }
    },
    "lmstudio": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LM Studio (local)",
      "options": {
        "baseURL": "http://127.0.0.1:1234/v1"
      },
      "models": {
        "google/gemma-3n-e4b": {
          "name": "Gemma 3n-e4b (local)"
        }
      }
    }
  },
  "cerebras": {
    "type": "api",
    "key": "csk-something-something"
  }
}

I do think Cerebras should be top-level since it gives away lot of free stuff & its super duper fast.

Would love to know how to setup Cerebras properly? I am stuck in a loop.

Originally created by @deadcoder0904 on GitHub (Jul 14, 2025). Originally assigned to: @jayair on GitHub. I like how BAML does it - https://docs.boundaryml.com/ref/llm-client-providers/overview This works for Programmatic SEO as well. I wished the CLI had OpenAI Compatible option too or specific providers like Cerebras, Moonshot, and every new one. Kilo Code's team adds them extremely fast. That's one place to look at. Also, search is not working well. I did find https://opencode.ai/docs/models/ while writing this issue but took too long. I'm still confused where to put API Key for Open AI Compatible provider. Okay, I found it below baseUrl but for some reason, I can't set `cerebras` up. I get this: ``` █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ┌ Add credential │ ◇ Select provider │ Other │ ◇ Enter provider id │ cerebras │ ▲ This only stores a credential for cerebras - you will need configure it in opencode.json, check the docs for examples. │ ◇ Enter your API key │ ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ │ └ Done █▀▀█ █▀▀█ █▀▀ █▀▀▄ █▀▀ █▀▀█ █▀▀▄ █▀▀ █░░█ █░░█ █▀▀ █░░█ █░░ █░░█ █░░█ █▀▀ ▀▀▀▀ █▀▀▀ ▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ┌ Add credential │ ■ Select provider │ Anthropic │ ``` And it loops again to asking for provider. This is my config on Mac at `~/.local/share/opencode/auth.json`: ```json { "$schema": "https://opencode.ai/config.json", "autoupdate": false, "model": "cerebras/qwen-3-235b-a22b", "provider": { "cerebras": { "npm": "@ai-sdk/openai-compatible", "name": "Cerebras", "options": { "baseURL": "https://api.cerebras.ai/v1", "apiKey": "csk-something-something" }, "models": { "qwen-3-235b-a22b": { "name": "Qwen-3-235b-a22b" }, "qwen-3-32b": { "name": "Qwen-3-32b" }, "llama3.1-8b": { "name": "Llama3.1-8b" }, "llama-3.3-70b": { "name": "Llama-3.3-70b" }, "deepseek-r1-distill-llama-70b": { "name": "Deepseek-r1-distill-llama-70b" }, "llama-4-scout-17b-16e-instruct": { "name": "Llama-4-scout-17b-16e-instruct" } } }, "lmstudio": { "npm": "@ai-sdk/openai-compatible", "name": "LM Studio (local)", "options": { "baseURL": "http://127.0.0.1:1234/v1" }, "models": { "google/gemma-3n-e4b": { "name": "Gemma 3n-e4b (local)" } } } }, "cerebras": { "type": "api", "key": "csk-something-something" } } ``` I do think Cerebras should be top-level since it gives away lot of free stuff & its super duper fast. Would love to know how to setup Cerebras properly? I am stuck in a loop.
yindo closed this issue 2026-02-16 17:27:56 -05:00
Author
Owner

@deadcoder0904 commented on GitHub (Jul 14, 2025):

Okay, I figured out how to run Cerebras but took me a while.

Another problem is global & local config. I had my global config & thought Opencode would use that but it didn't.

So I created opencode.json in the root directory & pasted this:

{
	"$schema": "https://opencode.ai/config.json",
	"autoupdate": false,
	"model": "cerebras/qwen-3-235b-a22b",
	"provider": {
		"cerebras": {
			"npm": "@ai-sdk/cerebras",
			"name": "Cerebras",
			"options": {
				"baseURL": "https://api.cerebras.ai/v1",
				"apiKey": "csk-something-something"
			},
			"models": {
				"qwen-3-235b-a22b": {
					"name": "Qwen-3-235b-a22b"
				},
				"qwen-3-32b": {
					"name": "Qwen-3-32b"
				},
				"llama3.1-8b": {
					"name": "Llama3.1-8b"
				},
				"llama-3.3-70b": {
					"name": "Llama-3.3-70b"
				},
				"deepseek-r1-distill-llama-70b": {
					"name": "Deepseek-r1-distill-llama-70b"
				},
				"llama-4-scout-17b-16e-instruct": {
					"name": "Llama-4-scout-17b-16e-instruct"
				}
			}
		},
		"lmstudio": {
			"npm": "@ai-sdk/openai-compatible",
			"name": "LM Studio (local)",
			"options": {
				"baseURL": "http://127.0.0.1:1234/v1"
			},
			"models": {
				"google/gemma-3n-e4b": {
					"name": "Gemma 3n-e4b (local)"
				}
			}
		}
	}
}

Another mistake I had was using @ai-sdk/openai-compatible instead of @ai-sdk/cerebras because in BAML, Cerebras was OpenAI Compatible so I used my muscle memory there.

In any case, after doing this, I tried running opencode & it worked. It should have read global file though if local didn't exist imo.

Anyways, love this project (especially the UI) so can't judge on anything else but it needs the basics to be more easy so any noob can set it up instead of wasting 15-30 mins on this. I'll keep this open since it has many different suggestions that I think should be fixed.

@deadcoder0904 commented on GitHub (Jul 14, 2025): Okay, I figured out how to run Cerebras but took me a while. Another problem is global & local config. I had my global config & thought Opencode would use that but it didn't. So I created `opencode.json` in the root directory & pasted this: ```json { "$schema": "https://opencode.ai/config.json", "autoupdate": false, "model": "cerebras/qwen-3-235b-a22b", "provider": { "cerebras": { "npm": "@ai-sdk/cerebras", "name": "Cerebras", "options": { "baseURL": "https://api.cerebras.ai/v1", "apiKey": "csk-something-something" }, "models": { "qwen-3-235b-a22b": { "name": "Qwen-3-235b-a22b" }, "qwen-3-32b": { "name": "Qwen-3-32b" }, "llama3.1-8b": { "name": "Llama3.1-8b" }, "llama-3.3-70b": { "name": "Llama-3.3-70b" }, "deepseek-r1-distill-llama-70b": { "name": "Deepseek-r1-distill-llama-70b" }, "llama-4-scout-17b-16e-instruct": { "name": "Llama-4-scout-17b-16e-instruct" } } }, "lmstudio": { "npm": "@ai-sdk/openai-compatible", "name": "LM Studio (local)", "options": { "baseURL": "http://127.0.0.1:1234/v1" }, "models": { "google/gemma-3n-e4b": { "name": "Gemma 3n-e4b (local)" } } } } } ``` Another mistake I had was using `@ai-sdk/openai-compatible` instead of `@ai-sdk/cerebras` because in BAML, Cerebras was OpenAI Compatible so I used my muscle memory there. In any case, after doing this, I tried running `opencode` & it worked. It should have read global file though if local didn't exist imo. Anyways, love this project (especially the UI) so can't judge on anything else but it needs the basics to be more easy so any noob can set it up instead of wasting 15-30 mins on this. I'll keep this open since it has many different suggestions that I think should be fixed.
Author
Owner

@ntovarsolorzano commented on GitHub (Jul 18, 2025):

Lol, I came for the same reason. I was looking for a similar post so I may not rise a 'duplicated Issue'.
Have more than 2h... and I'm still trying to add Kimi-K2 into opencode 😭😭😭
It is openai-library compatible, should be easy. And indeed, the global and the local are different. I can make it into the local, but the idea is to add Kimi-K2 globally. I came across the same issues as the ones posted here.

So your 'solution' was to clone it locally and work with the local version?
Does it give you any issues by working in other directories?

My opencode.json works but only in locally, I can't make it work globally. Probably I am missing a simple step somewhere.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "moonshot": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Moonshot AI",
      "api": "https://api.moonshot.ai/v1",
      "env": [
        "MOONSHOT_API_KEY"
      ],
      "models": {
        "kimi-k2-0711-preview": {
          "name": "Kimi K2"
        }
      }
    }
  },
  "mcp": {
    "weather": {
      "type": "local",
      "command": [
        "opencode",
        "x",
        "@h1deya/mcp-server-weather"
      ]
    }
  }
}

Update: It works now! 😭🙌
I followed this advice So I created opencode.json in the root directory & pasted this.

  1. 'As-it-is' now, your root directory is whatever folder you an in now, and you plan to work on. Also called 'project directory'.
  2. Go to that directory and create the opencode.json in my case, I it is the same opencode.json as in Github, but I added Kimi-K2.

Thank you !!

@ntovarsolorzano commented on GitHub (Jul 18, 2025): Lol, I came for the same reason. I was looking for a similar post so I may not rise a 'duplicated Issue'. Have more than 2h... and I'm still trying to add Kimi-K2 into opencode 😭😭😭 It is openai-library compatible, should be easy. And indeed, the global and the local are different. I can make it into the local, but the idea is to add Kimi-K2 globally. I came across the same issues as the ones posted here. So your 'solution' was to clone it locally and work with the local version? Does it give you any issues by working in other directories? My `opencode.json` works but only in locally, I can't make it work globally. Probably I am missing a simple step somewhere. ``` { "$schema": "https://opencode.ai/config.json", "provider": { "moonshot": { "npm": "@ai-sdk/openai-compatible", "name": "Moonshot AI", "api": "https://api.moonshot.ai/v1", "env": [ "MOONSHOT_API_KEY" ], "models": { "kimi-k2-0711-preview": { "name": "Kimi K2" } } } }, "mcp": { "weather": { "type": "local", "command": [ "opencode", "x", "@h1deya/mcp-server-weather" ] } } } ``` Update: It works now! 😭🙌 I followed this advice `So I created opencode.json in the root directory & pasted this`. 1. 'As-it-is' now, your `root` directory is whatever folder you an in now, and you plan to work on. Also called 'project directory'. 2. Go to that directory and create the `opencode.json` in my case, I it is the same `opencode.json` as in Github, but I added Kimi-K2. Thank you !!
Author
Owner

@jayair commented on GitHub (Jul 18, 2025):

Yeah I think we should do something like the doc you linked to.

@jayair commented on GitHub (Jul 18, 2025): Yeah I think we should do something like the doc you linked to.
Author
Owner

@jayair commented on GitHub (Jul 30, 2025):

Just added this doc: https://opencode.ai/docs/providers/

Going to start listing more providers as we go along

@jayair commented on GitHub (Jul 30, 2025): Just added this doc: https://opencode.ai/docs/providers/ Going to start listing more providers as we go along
Author
Owner

@opencode-agent[bot] commented on GitHub (Jul 30, 2025):

Created PR #1441

Adding%20providers%20documentation%20for%20OpenCode
opencode session  |  github run

@opencode-agent[bot] commented on GitHub (Jul 30, 2025): Created PR #1441 <a href="https://opencode.ai/s/zHSn6S6t"><img width="200" alt="Adding%20providers%20documentation%20for%20OpenCode" src="https://social-cards.sst.dev/opencode-share/QWRkaW5nIHByb3ZpZGVycyBkb2N1bWVudGF0aW9uIGZvciBPcGVuQ29kZQ==.png?model=anthropic/claude-sonnet-4-20250514&version=0.3.86&id=zHSn6S6t" /></a> [opencode session](https://opencode.ai/s/zHSn6S6t)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/16636133490)
Author
Owner

@jayair commented on GitHub (Jul 31, 2025):

I didn't ask for this PR but it's not bad wtf

@jayair commented on GitHub (Jul 31, 2025): I didn't ask for this PR but it's not bad wtf
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#699