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 user
  • maxRequests: Maximum number of requests allowed
  • duration: Time period for rate limiting (“minute”, “hour”, “day”, “week”, “month”, “year”)