|
| 1 | +--- |
| 2 | +title: "Alibaba Cloud Bailian" |
| 3 | +description: "Configure Alibaba Cloud Bailian (百炼 / DashScope) in GoModel, including the max_tokens compatibility shim for models like Qwen." |
| 4 | +icon: "cloud" |
| 5 | +--- |
| 6 | + |
| 7 | +Bailian (百炼) is Alibaba Cloud's model-as-a-service platform for the Qwen |
| 8 | +family of models. GoModel routes to Bailian through its OpenAI-compatible |
| 9 | +endpoint (`/compatible-mode/v1`). |
| 10 | + |
| 11 | +Because Bailian deprecated `max_tokens` in April 2026 in favor of |
| 12 | +`max_completion_tokens`, GoModel automatically maps the standard |
| 13 | +`max_tokens` field to `max_completion_tokens` for every request — no |
| 14 | +client change required. |
| 15 | + |
| 16 | +## Configure |
| 17 | + |
| 18 | +```bash |
| 19 | +BAILIAN_API_KEY=... |
| 20 | +``` |
| 21 | + |
| 22 | +Or in `config.yaml`: |
| 23 | + |
| 24 | +```yaml |
| 25 | +providers: |
| 26 | + bailian: |
| 27 | + type: bailian |
| 28 | + api_key: "${BAILIAN_API_KEY}" |
| 29 | + # base_url: "https://dashscope.aliyuncs.com/compatible-mode/v1" |
| 30 | +``` |
| 31 | + |
| 32 | +## Base URLs |
| 33 | + |
| 34 | +Bailian's OpenAI-compatible API is available in multiple regions. Set |
| 35 | +`BAILIAN_BASE_URL` to switch: |
| 36 | + |
| 37 | +| Region | URL | |
| 38 | +| ------ | --- | |
| 39 | +| Beijing (default) | `https://dashscope.aliyuncs.com/compatible-mode/v1` | |
| 40 | +| Singapore | `https://{workspace-id}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1` | |
| 41 | +| Frankfurt | `https://{workspace-id}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1` | |
| 42 | +| Hong Kong | `https://{workspace-id}.cn-hongkong.maas.aliyuncs.com/compatible-mode/v1` | |
| 43 | + |
| 44 | +## Model IDs |
| 45 | + |
| 46 | +Common Qwen model identifiers — check the [Bailian model |
| 47 | +list](https://www.alibabacloud.com/help/zh/model-studio/model-list) for the |
| 48 | +current catalog: |
| 49 | + |
| 50 | +| Model | Example ID | |
| 51 | +| ----- | ---------- | |
| 52 | +| Qwen 3.7 Max | `qwen3.7-max` | |
| 53 | +| Qwen 3.7 Plus | `qwen3.7-plus` | |
| 54 | +| Qwen 3.6 Flash | `qwen3.6-flash` | |
| 55 | +| Qwen 3 Max | `qwen3-max` | |
| 56 | +| Qwen 3 Plus | `qwen3-plus` | |
| 57 | +| Qwen 3 Flash | `qwen3-flash` | |
| 58 | +| Qwen 3 Coder Plus | `qwen3-coder-plus` | |
| 59 | +| Text Embedding | `text-embedding-v3` | |
| 60 | + |
| 61 | +## `max_tokens` compatibility |
| 62 | + |
| 63 | +Bailian deprecated `max_tokens` on 2026-04-20 (effective 2026-05-30). |
| 64 | +All Bailian models now require `max_completion_tokens` instead. |
| 65 | + |
| 66 | +GoModel transparently maps the standard `max_tokens` parameter to |
| 67 | +`max_completion_tokens` for every bailian model — send `max_tokens` as you |
| 68 | +normally would, and GoModel rewrites it before forwarding to Bailian. |
| 69 | + |
| 70 | +```bash |
| 71 | +# max_tokens=4096 is automatically sent as max_completion_tokens=4096 |
| 72 | +curl http://localhost:8080/v1/chat/completions \ |
| 73 | + -H "Content-Type: application/json" \ |
| 74 | + -d '{ |
| 75 | + "model": "qwen3-max", |
| 76 | + "messages": [{"role": "user", "content": "Hello"}], |
| 77 | + "max_tokens": 4096 |
| 78 | + }' |
| 79 | +``` |
| 80 | + |
| 81 | +## Supported features |
| 82 | + |
| 83 | +| Feature | Supported | |
| 84 | +| ------- | :-------: | |
| 85 | +| Chat completions | ✅ | |
| 86 | +| Streaming chat | ✅ | |
| 87 | +| Responses (`/v1/responses`) | ✅ (translated to chat) | |
| 88 | +| Embeddings | ✅ (configure model IDs via `BAILIAN_MODELS`) | |
| 89 | +| Files (`/v1/files`) | ✅ | |
| 90 | +| Batches (`/v1/batches`) | ✅ | |
| 91 | +| Passthrough (`/p/bailian/...`) | ✅ | |
| 92 | + |
| 93 | +<Note> |
| 94 | + Embedding models (`text-embedding-v3`, `text-embedding-v4`) are served by |
| 95 | + the compatible-mode API but are **not** auto-discovered from the upstream |
| 96 | + `/v1/models` endpoint. Set `BAILIAN_MODELS=text-embedding-v3,text-embedding-v4` |
| 97 | + or use `CONFIGURED_PROVIDER_MODELS_MODE=allowlist` to make them available. |
| 98 | +</Note> |
| 99 | + |
| 100 | +## References |
| 101 | + |
| 102 | +- [Bailian documentation](https://www.alibabacloud.com/help/zh/model-studio/) |
| 103 | +- [OpenAI-compatible API reference](https://www.alibabacloud.com/help/zh/model-studio/compatibility-with-openai-responses-api) |
| 104 | +- [Qwen model list](https://www.alibabacloud.com/help/zh/model-studio/model-list) |
0 commit comments