0G Gateway is a OpenAI compatible API gateway connecting 0G Serving Broker.
- Deployed VPS Endpoint:
http://0g-gateway.longcipher.com:3000/v1
- Deployed Phala Cloud Endpoint:
https://176f7ae0891796d17e505edcb4a9a5177bd59b4b-3000.dstack-prod5.phala.network/v1
Check the /health
response to see if the service is running properly.
Directly interfacing with underlying AI infrastructure (like the 0G Serving Broker) often involves complex wallet authentication, gas fee management, and other operations. This significantly increases the barrier to entry for developers and hinders the widespread adoption of AI applications. Existing OpenAI-compatible applications face considerable rework to migrate to decentralized, high-performance 0G Serving Broker services.
0G Gateway aims to create a user-friendly API Gateway, serving as a bridge between existing OpenAI-compatible applications and the 0G Serving Broker. Developers can forward requests to the 0G Serving Broker with a simple configuration, enjoying its high-performance, low-cost AI inference capabilities without modifying existing code.
-
OpenAI-Compatible RESTful API: Fully compatible with OpenAI API interfaces, enabling seamless integration without any code modifications to existing applications.
-
Zero-Authentication Experience: Simplifies the user authentication process by integrating
@0glabs/0g-serving-broker
, eliminating the need for wallets and gas fees to utilize AI services. -
High-Performance Proxy: Use Bun as node runtime and Hono as web framework, optimizes the request forwarding process to ensure low latency and high throughput, improving the response speed of AI applications.
-
Multi-Runtime: Thanks to using Hono as the web framework, multiple deployment methods are supported, making it easy to deploy to Phala Cloud, Bun, Deno, Node.js, Cloudflare Workers, AWS Lambda, Vercel, and similar services.
-
Phala Cloud TEE: Deployment within a secure TEE ensures the service is trusted and verifiable.
- Integrate more capabilities from the 0G chain.
- Support caching and token optimization strategies to reduce costs.
- Build a vibrant AI service marketplace, facilitating easier transactions between developers and service providers.
To install dependencies:
bun install
To run:
bun dev # for dev
bun prod # for prod
To test:
cd openai-chat
uv run openai-chat
docker build -t 0g-gateway .
docker run -p 3000:3000 -e PRIVATE_KEY="<your_private_key>" 0g-gateway