Skip to content

Docs for OpenAI Compatible providers like Cerebras #976

Closed

Description

@deadcoder0904

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.

Activity

  1. deadcoder0904 commented on Jul 14, 2025

    @deadcoder0904
    Author

    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.

  2. ntovarsolorzano commented on Jul 18, 2025

    @ntovarsolorzano

    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 !!

  3. jayair commented on Jul 18, 2025

    @jayair
    Contributor

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

  4. self-assigned this
    on Jul 18, 2025
  5. jayair commented on Jul 30, 2025

    @jayair
    Contributor

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

    Going to start listing more providers as we go along

  6. opencode-agent commented on Jul 30, 2025

    @opencode-agent
    Contributor

    Created PR #1441

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

  7. jayair commented on Jul 31, 2025

    @jayair
    Contributor

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

  8. added a commit that references this issue on Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions