How shenald-dev/one-api works
one-api is presented in the README as an OpenAI-compatible gateway for multiple LLM providers. However, the sampled implementation of its sole source file validates chat-completion requests and returns a fixed mock response; it shows no provider dispatch or streaming. The graph therefore describes the implemented request path rather than treating documented provider support as verified. The README also describes configuration-driven routing, but the sampled source does not show that routing. Evidence is limited to the README and src/index.js.
Main entry points: index.js Express App
Components 10
HTTP API
- Express App
src/index.js - Health Endpoint
src/index.js - Chat Completions
src/index.js - Request Validation
src/index.js
Response Handling
- Mock Response
src/index.js - Error Handlers
src/index.js
Runtime Support
- CORS Policy
src/index.js - Security Headers
src/index.js - Compression
src/index.js
Other components
- API Client
Connections 9
- API Client → Express App: sends requests
README.md - Express App → Health Endpoint: routes health
src/index.js - Express App → Chat Completions: routes completions
src/index.js - Chat Completions → Request Validation: validates payload
src/index.js - Chat Completions → Mock Response: returns fixed response
src/index.js - Express App → Error Handlers: handles parse errors
src/index.js - Express App → CORS Policy: applies policy
src/index.js - Express App → Security Headers: applies headers
src/index.js - Chat Completions → Compression: compresses responses
src/index.js