Skip to main content
Z.ai provides GLM models through an API compatible with the OpenAI SDK. Set the OpenAI client’s base_url to Z.ai and use openinference-instrumentation-openai to send LLM traces to Phoenix.
This page instruments OpenAI SDK calls to Z.ai’s OpenAI-compatible endpoint. It is not a separate Z.ai-specific OpenInference instrumentor.

Install

Setup

Add your Z.ai API key as an environment variable:
Connect your application to Phoenix with the register function:

Run Z.ai

Observe

Now that you have tracing set up, all invocations of the OpenAI client pointed at Z.ai 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 Z.ai: Use your Z.ai API key, not an OpenAI key
  • Model not found: Replace glm-5.3 with a model available in your Z.ai account. Some Z.ai plans use a different OpenAI-compatible base URL, so confirm the endpoint in your Z.ai console

Resources

Z.ai OpenAI SDK Guide

OpenInference OpenAI Instrumentation