Skip to main content

LLM Providers

cosh-core connects to multiple LLM providers via the OpenAI-compatible API protocol. All providers use streaming SSE output and support function calling.

Supported Providers

Provider TypeProfileDescription
dashscopeDashScopeAlibaba Cloud Bailian (Qwen series), supports thinking
aliyunSysOMAlibaba Cloud AK/SK signature authentication (ROA style)
openaiOpenAIOpenAI official API, uses max_completion_tokens
deepseekDeepSeekDeepSeek API, supports thinking
OtherGenericAny OpenAI-compatible endpoint

Configuration

Configure providers in ~/.copilot-shell/config.toml:

[ai]
active_model = "qwen-plus"

[ai.providers.dashscope]
type = "dashscope"
base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
api_key = "" # Or via DASHSCOPE_API_KEY environment variable
model = "qwen-plus"

[ai.providers.aliyun]
type = "aliyun"
access_key_id = "" # Or ALIBABA_CLOUD_ACCESS_KEY_ID
access_key_secret = "" # Or ALIBABA_CLOUD_ACCESS_KEY_SECRET
model = "qwen-plus"

[ai.providers.openai]
type = "openai"
base_url = "https://api.openai.com/v1"
api_key = "" # Or OPENAI_API_KEY
model = "gpt-4o"

[ai.providers.deepseek]
type = "deepseek"
base_url = "https://api.deepseek.com/v1"
api_key = ""
model = "deepseek-chat"

Provider Profile Differences

Behavioral differences across profiles in API requests:

Profilemax_tokens FieldThinking FieldAuthentication
Genericmax_tokensBearer token
DashScopemax_tokensreasoning_contentBearer token
OpenAImax_completion_tokensBearer token
DeepSeekmax_tokensreasoning_contentBearer token
SysOM (aliyun)AK/SK signature

Runtime Switching

Dynamically switch models via JSONL control protocol:

{"type":"control_request","request_id":"sw-1","request":{"subtype":"switch_model","model":"qwen-max"}}

Or override via CLI arguments:

cosh-core --headless --model qwen-max

Environment variable override:

COSH_MODEL=qwen-max cosh-core --headless

Authentication Priority

  1. CLI --model argument → selects corresponding provider config
  2. Environment variables (DASHSCOPE_API_KEY, ALIBABA_CLOUD_ACCESS_KEY_*)
  3. Values in config.toml [ai.providers.<name>]
  4. All empty → triggers interactive authentication flow (sends auth_required to Shell)

Generation Parameters

ParameterDefaultDescription
max_tokens4096Maximum generated tokens
temperatureSampling temperature (uses provider default if not set)
streamtrueAlways stream output

Custom parameters can be passed via extra_params in the [ai.providers.<name>] section of config.toml.