Delegated Inference
Allow your users to bring their own Iris subscription to your application. By integrating Ave Connector, you can route AI inference requests through the user's Iris account, saving you API costs while providing them with premium models.
1 How it works
1. Connect
User authenticates via Ave Connector and grants your app access to their Iris account.
2. Request
Your app sends inference requests to the Iris API using the delegated token.
3. Generate
Iris processes the request using the user's subscription quota and returns the response.
2 Authentication Flow
Iris uses Ave Connector with the OAuth 2.0 PKCE flow. To request access to Iris Delegated Inference, you must specify the iris:inference resource.
const AVE_CONNECT_URL = "https://aveid.net/connect";
const CLIENT_ID = "your_ave_client_id";
const REDIRECT_URI = "https://your-app.com/callback";
// Generate PKCE verifier and challenge
const codeVerifier = generateRandomString(64);
const codeChallenge = await generateCodeChallenge(codeVerifier);
// Store verifier in session/local storage
sessionStorage.setItem("pkce_verifier", codeVerifier);
// Redirect user to Ave
const url = new URL(AVE_CONNECT_URL);
url.searchParams.set("client_id", CLIENT_ID);
url.searchParams.set("redirect_uri", REDIRECT_URI);
url.searchParams.set("resource", "iris:inference"); // Required for Iris
url.searchParams.set("scope", "iris.infer"); // Required scope
url.searchParams.set("mode", "user_present");
url.searchParams.set("code_challenge", codeChallenge);
url.searchParams.set("code_challenge_method", "S256");
window.location.href = url.toString();After the user approves the connection, they will be redirected back to your redirect_uri with a code parameter. Exchange this code for an access token using the Ave API.
3 Making API Requests
Once you have the delegated access token, you can make requests to the Iris API. The API is compatible with standard chat completion formats.
const IRIS_API_URL = "https://incredible-lemur-807.convex.site";
const token = "delegated_token_from_ave";
const response = await fetch(`${IRIS_API_URL}/delegated/infer`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
body: JSON.stringify({
model: "openai/gpt-4o-mini",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello, Iris!" }
],
userPresent: true // Must match the mode requested during OAuth
})
});
const data = await response.json();
console.log(data.content); // The generated responseStreaming Support
For real-time responses, use the /delegated/infer/stream endpoint. It returns a Server-Sent Events (SSE) stream compatible with standard streaming parsers.
POST /delegated/infer/stream