ZtoApi  by libaxuan

Z.ai GLM-4.6 API proxy with OpenAI compatibility

Created 2 months ago
267 stars

Top 95.9% on SourcePulse

GitHubView on GitHub
Project Summary

Summary

This project provides an OpenAI-compatible API proxy for Z.ai's GLM-4.6 model. It targets developers seeking to integrate Z.ai's capabilities into existing applications built around the OpenAI API standard, offering a seamless way to leverage advanced models without modifying client code.

How It Works

The proxy acts as an intermediary, accepting requests formatted for OpenAI's API and forwarding them to the Z.ai GLM-4.6 backend. It translates responses back into the OpenAI format, supporting both standard and streaming outputs. Key features include API key authentication, optional anonymous access via auto-generated tokens, and enhanced observability through a real-time dashboard.

Quick Start & Requirements

  • Installation: Clone the repository and run go run main.go or use the provided ./start.sh script. Docker images are also available.
  • Prerequisites: Go 1.23 or higher is required. An optional Z.ai access token (ZAI_TOKEN) can be configured via environment variables for authenticated access.
  • Deployment: Supports local setup, Docker deployment, and deployment on platforms like Render.
  • Documentation: API documentation is available at http://localhost:9090/docs, and a real-time monitoring dashboard is accessible at http://localhost:9090/dashboard.

Highlighted Details

  • OpenAI API Compatibility: Seamlessly integrates with tools expecting OpenAI API endpoints and formats.
  • Streaming Support: Enables real-time, chunked responses for improved user experience.
  • Recent Fixes: Addresses critical 426 client version errors with updated client validation, User-Agent, and SHA-256 signature implementation.
  • Real-time Dashboard: Provides live statistics on API requests, response times, and recent activity.
  • Configurability: Extensive environment variable support for flexible deployment and feature toggling (e.g., ENABLE_THINKING, DASHBOARD_ENABLED).
  • Anonymous Mode: Automatically generates random tokens for anonymous usage when ZAI_TOKEN is not provided.

Maintenance & Community

The project is a fork of OpenAI-Compatible-API-Proxy-for-Z with secondary development. Specific community links, contribution guidelines beyond standard PR/Issue submission, or roadmap details are not detailed in the README. The latest update mentioned addresses a 426 error.

Licensing & Compatibility

The project is released under the permissive MIT License, allowing for broad compatibility with commercial and closed-source applications.

Limitations & Caveats

Requires Go 1.23+. Functionality is dependent on the Z.ai GLM-4.6 model's availability and API stability. The "anonymous mode" relies on auto-generated tokens, which may have implicit rate limits or behavioral changes dictated by Z.ai. The project description mentions a "low-key local 127.0.0.1 version," suggesting a primary focus on local development, despite supporting Docker and Render deployments. The future date mentioned for the latest update (2025-09-30) is unusual.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
5
Star History
30 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.