Skip to main content
Qwen models are available through Alibaba Cloud Model Studio, which provides an OpenAI-compatible API mode. Configure the OpenAI Python client with your Model Studio endpoint and use openinference-instrumentation-openai to capture spans in Phoenix.
This page instruments OpenAI SDK calls to Alibaba Cloud Model Studio’s OpenAI-compatible endpoint. It is not a separate Qwen-specific OpenInference instrumentor.

Install

Setup

Add your DashScope or Model Studio API key and the OpenAI-compatible base URL for your region as environment variables:
Alibaba Cloud may provide a workspace-specific or regional compatible-mode endpoint. Replace QWEN_BASE_URL with the endpoint shown in your Model Studio console if it differs.
Connect your application to Phoenix with the register function:

Run Qwen

Observe

Now that you have tracing set up, all invocations of the OpenAI client pointed at Qwen will be streamed to your running Phoenix for observability and evaluation. Each call appears as a ChatCompletion LLM span with the prompt, response, model name, token usage, and latency.

Common Issues

  • Spans missing: register(..., auto_instrument=True) must run before your application sends requests, and openinference-instrumentation-openai must be installed in the same environment
  • 401 from Model Studio: Use your DashScope or Model Studio API key, not an OpenAI key
  • Endpoint or model errors: Confirm QWEN_BASE_URL matches your Model Studio region or workspace, and replace qwen-plus with an available Qwen model

Resources

Model Studio OpenAI Compatibility

OpenInference OpenAI Instrumentation