DashScope serves the Qwen model family through an OpenAI-compatible Chat Completions API, so Qwen Code CLI can talk to it natively.
Create an AI Model Provider entity to define your connection and store your authentication credentials.
Create an AI Model entity to declare which upstream models are available, configure how client requests are routed, and specify which AI Model Provider to use.
kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_model_providers:
- ref: dashscope
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
name: dashscope
display_name: "Alibaba Cloud DashScope"
type: dashscope
config:
auth:
type: basic
headers:
- name: Authorization
value: !secret {source: !env DASHSCOPE_AUTH_HEADER}
ai_gateway_models:
- ref: my-qwen-dashscope
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
name: my-qwen-dashscope
display_name: "my-qwen-dashscope"
type: model
formats: [{ type: openai }]
config:
route:
paths: [/qwen-dashscope]
model:
body_param: model
values: [my-qwen-dashscope]
targets:
- name: qwen-plus
provider: dashscope
config:
type: dashscope
international: true
capabilities: [generate]
EOF
This example uses the following settings:
-
targets: Sends requests to qwen-plus through the dashscope provider.
-
targets[0].config.international: true: Uses DashScope’s international endpoint (dashscope-intl.aliyuncs.com); set it to false if your DashScope key belongs to a mainland China account.
-
capabilities: [generate]: Exposes the model at a /qwen-dashscope/chat/completions endpoint.