infer0 for Developers
infer0 lets your app offer BYO-provider AI inference via OAuth 2.0. Each of your end users connects their own provider account (OpenAI, Anthropic, etc.), and you call a single API.
How it works
Your app redirects user
to infer0 to authorize
User picks their
provider & approves
Your app receives
an access token
Call infer0 with
the access token
1. Register your app
Sign in to the infer0 dashboard and register your OAuth app at /dev/apps. You'll get a client_id and client_secret.
2. Authorization redirect
Send the user to infer0's authorization endpoint:
GET https://infer0.cgcoss.workers.dev/oauth/authorize?client_id=<client_id>&redirect_uri=<callback_url>&response_type=code
The user signs in (if needed), selects which provider to use, and approves the request.
infer0 redirects back to your callback with a code parameter.
3. Exchange code for tokens
POST https://infer0.cgcoss.workers.dev/v1/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=<code>
&client_id=<client_id>
&client_secret=<client_secret>
&redirect_uri=<callback_url>
Returns access_token (1 hour) and refresh_token (30 days).
4. Inference
POST/v1/chat/completions
OpenAI-compatible chat completions. Routes to the end user's configured provider and model automatically.
curl https://infer0.cgcoss.workers.dev/v1/chat/completions \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "Hello" }]
}'
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://infer0.cgcoss.workers.dev/v1",
apiKey: "<access_token>",
});
const chat = await client.chat.completions.create({
model: "(ignored — uses user's configured model)",
messages: [{ role: "user", content: "Hello" }],
});
Refreshing the access token
POST https://infer0.cgcoss.workers.dev/v1/oauth/refresh
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token
&refresh_token=<refresh_token>
&client_id=<client_id>
&client_secret=<client_secret>
Managing provider configs
Your end users manage their own provider keys through the infer0 dashboard. Your app never sees or handles their API keys.