How to use Claude Code with Kimi K2
Z.AI has released GLM-4.5 which is an open source (open model) primarily built for agent-oriented apps.
It is as good as commercial models.
Similar to Kimi K2, they also provide Anthropic compatible API endpoint which we can use with Claude Code
How to do it?
Just set these environment variables before running Claude Code cli
export ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
export ANTHROPIC_AUTH_TOKEN=YOUR_MOONSHOT_API
And now, you can start claude code as usual
claude
How to get API Key?
Go to https://z.ai/model-api
Login with you z.ai account (same as z.ai chat account)
They don’t offer any free credits so you’ll need to add some money to try out their API endpoint.
Happy cost optimization!
Was this content helpful?
Help us improve by giving us your feedback.