Features
User Rate Limiting
Control API usage on a per-user basis
Ultra AI provides user-based rate limiting to help you manage API usage and control costs.
Configuration
To implement rate limiting, include a user
parameter in your API requests:
import OpenAI from "openai"
const openai = new OpenAI({
apiKey: "your-ultraai-api-key",
baseURL: "https://api.ultraai.app/v1",
})
const completion = await openai.chat.completions.create({
model: JSON.stringify({
models: ["openai:gpt-4o"],
}),
messages: [{ role: "user", content: "Hello, how are you?" }],
user: JSON.stringify({
id: "user123",
maxRequests: 100,
duration: "hour",
// i.e. 100 requests per hour for user `user123`
}),
})
Parameters
id
: Unique identifier for the usermaxRequests
: Maximum number of requests allowedduration
: Time period for rate limiting (“minute”, “hour”, “day”, “week”, “month”, “year”)