PrimeAgent APIs: Complete Guide to Supported LLM Providers

PrimeAgent supports 9 built-in LLM API identifiers including OpenAI, Anthropic, Mistral, Azure OpenAI, Google Gemini/Vertex, Amazon Bedrock, and OpenAI Codex, defined in the KnownApi union type.

PrimeAgent abstracts a wide variety of large language model backends through a unified interface. According to the PrimeIntellect-ai/prime-agent source code, the system enumerates all supported PrimeAgent APIs in a central type definition, enabling type-safe provider selection and runtime routing.

Core API Types and Enumeration

The definitive list of supported API identifiers lives in packages/ai/src/types.ts. This file declares the KnownApi union type, which represents the complete set of built-in providers that the system recognizes.

The KnownApi Union Type

The type definition spans lines 6-15 and defines the following API identifiers:

  • openai-completions – Standard OpenAI Chat and Completion endpoints for GPT models (gpt-4, gpt-3.5-turbo, etc.)
  • mistral-conversations – Mistral AI conversational models
  • openai-responses – OpenAI Chat Completion with streaming support
  • azure-openai-responses – Azure OpenAI Service managed deployments
  • openai-codex-responses – OpenAI Codex code-generation models (code-davinci-002)
  • anthropic-messages – Anthropic Claude chat models
  • bedrock-converse-stream – Amazon Bedrock conversational models with streaming
  • google-generative-ai – Google Gemini 1 (Generative AI) models
  • google-vertex – Google Vertex AI hosted LLMs

The generic type Api = KnownApi | (string & {}) permits extension for custom implementations, but the provider registration machinery only accepts the enumerated KnownApi values for built-in functionality.

How PrimeAgent Routes API Requests

The PrimeAgent APIs drive transport selection, payload shape, and feature flags throughout the system. Three critical files handle the routing logic:

Provider Registration

packages/ai/src/providers/register-builtins.ts maps each KnownApi string to its concrete implementation class. This registration layer determines how the system formulates HTTP, SSE, or WebSocket requests for each provider.

Model Catalog

packages/ai/src/models.generated.ts (auto-generated by scripts/generate-models.ts) maintains the mapping between model IDs and their corresponding api field. Each model definition references one of the nine API identifiers above.

Runtime Streaming

The StreamFunction signature in packages/ai/src/stream.ts accepts a model: Model<Api> parameter. The model.api property must match one of the supported strings, allowing the unified stream function to dispatch to the correct provider implementation without changing the calling code.

Practical Usage Examples

The following TypeScript snippets demonstrate how to select models by API type and invoke streaming requests using the unified interface.

import { getModelById, stream } from "packages/ai/src/index.js";
import type { Model } from "packages/ai/src/types.js";

// Select an OpenAI model
const gpt4 = await getModelById("gpt-4");   // model.api === "openai-completions"

// Stream a chat completion
const ctx = { systemPrompt: "You are a helpful assistant.", messages: [] };
const opts = { temperature: 0.7 };
const eventStream = stream(gpt4, ctx, opts);
for await (const ev of eventStream) {
  if (ev.type === "text_delta") console.log(ev.delta);
}

// Switch to Anthropic without changing implementation logic
const claude = await getModelById("claude-2.1"); // model.api === "anthropic-messages"
const claudeStream = stream(claude, ctx, opts);
for await (const ev of claudeStream) {
  if (ev.type === "text_delta") console.log("[Claude] " + ev.delta);
}

The same stream function works across all PrimeAgent APIs; only the model identifier changes.

Summary

  • Nine built-in APIs are supported: OpenAI (completions, responses, Codex), Anthropic, Mistral, Azure OpenAI, Amazon Bedrock, and Google (Generative AI and Vertex).
  • Type-safe enumeration via KnownApi in packages/ai/src/types.ts prevents invalid provider strings.
  • Unified interface through stream() in packages/ai/src/stream.ts abstracts transport details.
  • Extensible architecture uses register-builtins.ts to map API identifiers to concrete provider implementations.
  • Runtime resolution relies on models.generated.ts to associate model IDs with their specific API handlers.

Frequently Asked Questions

What LLM providers does PrimeAgent support?

PrimeAgent supports nine built-in providers through the KnownApi union type: OpenAI (standard completions, streaming responses, and Codex), Anthropic Claude, Mistral AI, Azure OpenAI Service, Amazon Bedrock, and Google (both Generative AI and Vertex AI). These are enumerated in packages/ai/src/types.ts.

Can I add custom API providers to PrimeAgent?

While the Api type technically allows extension via KnownApi | (string & {}), the provider registration machinery in packages/ai/src/providers/register-builtins.ts only recognizes the nine built-in KnownApi values. To add truly custom providers, you must modify the registration logic to handle new API strings.

How does PrimeAgent determine which transport protocol to use?

The model.api property drives transport selection. Each API identifier maps to a concrete provider class in register-builtins.ts that encapsulates the specific HTTP, SSE, or WebSocket implementation details required for that service's protocol.

Where are the API mappings defined in the codebase?

The primary definitions reside in three locations: packages/ai/src/types.ts defines the KnownApi union, packages/ai/src/providers/register-builtins.ts maps these strings to implementation classes, and packages/ai/src/models.generated.ts associates individual model IDs with their respective API handlers.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →