DEV Community

SH-YYZ
SH-YYZ

Posted on

How I Built a Cost-Effective AI API Gateway for Chinese LLMs in 10 Minutes

How I Built a Cost-Effective AI API Gateway for Chinese LLMs in 10 Minutes

As an indie developer, I've been looking for ways to reduce API costs without sacrificing quality. OpenAI is great, but the cost adds up quickly.

I started exploring Chinese LLMs β€” they offer similar quality at a much lower price. But there's a problem: each provider has its own API format, payment system, and sometimes requires a Chinese phone number to register.

So I built a unified API gateway using an open-source tool called One API. It translates standard OpenAI-style requests into calls to various Chinese model providers.

Quick Demo

Here's what I did:

  1. Deployed One API on a VPS
  2. Added a channel for Zhipu AI (Chinese provider)
  3. Generated an API key
  4. Tested it with curl

Here's a sample call:


bash
curl http://aitokenshub.net:3000/v1/chat/completions \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-4-flash",
    "messages": [{"role": "user", "content": "Hello, introduce yourself"}]
  }'
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
aitokenhub profile image
SH-YYZ

Hi everyone πŸ‘‹ I'm the author. I built this because I couldn't afford OpenAI's API for my side projects. Happy to answer any questions about how it works!