Ultra AI’s AI Gateway provides a unified interface to access various AI providers through a single API. This feature simplifies integration and allows for easy switching between different AI models.

Supported Providers

Ultra AI supports a wide range of AI providers, including:

Supported Endpoints

  • /chat/completions
  • /embeddings

Usage

To use the AI Gateway, specify the desired models in your API request:

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", "anthropic:claude-3-5-sonnet-20240620"],
  }),
  messages: [{ role: "user", content: "Hello, how are you?" }],
})

Model Fallbacks

The AI Gateway will attempt to use the models in the order specified, falling back to the next model if necessary.

In the example above, the AI Gateway will first try to use the openai:gpt-4o model. If that model fails, it will try the anthropic:claude-3-5-sonnet-20240620 model.