Skip to content

OpenAI-compatible Gateway connecting 0G Serving Broker

Notifications You must be signed in to change notification settings

longcipher/0g-gateway

Repository files navigation

0G Gateway

Bun CI Docker Push

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.

Project Description

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.

Core Features

  • 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.

Future Vision

  • 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.

Run

To install dependencies:

bun install

To run:

bun dev # for dev
bun prod # for prod

To test:

cd openai-chat
uv run openai-chat

Use docker

docker build -t 0g-gateway .
docker run -p 3000:3000 -e PRIVATE_KEY="<your_private_key>" 0g-gateway

Slide

Demo

About

OpenAI-compatible Gateway connecting 0G Serving Broker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages