Skip to content

937bb/openai-compatible-api-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

OpenAI-Compatible API Router

Minimal examples for designing an OpenAI-compatible model router.

This repository is useful for developers who want to understand how a single API layer can route requests to different AI model providers while keeping client integration simple.

Maintained by ModelPort Global: https://www.modelportglobal.com/

What Is An API Router?

An API router receives a request from an application, checks the requested model, applies account or routing rules, and forwards the request to the appropriate upstream service.

Common use cases:

  • Route different models through one endpoint
  • Keep application code stable while changing providers
  • Track usage and cost in one place
  • Apply team-level access controls
  • Test new providers without rewriting clients

Typical model families in an aggregation layer may include domestic Chinese models such as DeepSeek, Qwen, and GLM, plus global models such as Claude and GPT.

Basic Request Shape

POST /v1/chat/completions
Authorization: Bearer <api-key>
Content-Type: application/json
{
  "model": "your-model-name",
  "messages": [
    { "role": "user", "content": "Explain API routing in one sentence." }
  ]
}

Example Routing Table

See examples/routes.json.

Design Checklist

  • Keep the external API compatible with popular SDKs
  • Validate account permissions before routing
  • Store only the logs needed for debugging and billing
  • Track prompt tokens, completion tokens, and total cost
  • Return clear error messages for missing models or invalid keys
  • Respect upstream provider terms and rate limits

Hosted Option

If you want a ready-to-use gateway instead of building your own router, try ModelPort Global:

Responsible Use

This repository is for legitimate API integration and routing patterns. Use only authorized API keys and permitted upstream services.

About

Minimal examples for designing an OpenAI-compatible model router

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors