Prime Agent LLM Providers and API Key Configuration: A Complete Developer Guide

Prime Agent supports nine major LLM providers including OpenAI, Anthropic, Google Gemini, Mistral, Azure OpenAI, and Amazon Bedrock, with API keys configured via environment variables defined in packages/ai/src/env-api-keys.ts.

Prime Agent by PrimeIntellect-ai provides a unified interface for multiple large language model providers. Understanding which Prime Agent LLM providers are available and how to authenticate them is essential for building agentic applications. The system registers all providers at startup through a centralized registry that maps API identifiers to streaming implementations.

Supported LLM Providers in Prime Agent

Prime Agent registers all built-in providers at startup through the registerBuiltInApiProviders() function in packages/ai/src/providers/register-builtins.ts. Each provider maps to a specific API identifier and implements lazy-loaded streaming handlers.

OpenAI and Azure OpenAI

Prime Agent includes four distinct OpenAI-related providers:

  • openai-completions (lines 49-55): Targets the OpenAI completions endpoint for models like gpt-4o-mini
  • openai-responses (lines 61-66): Uses the OpenAI chat-completion API for GPT-4 and similar models
  • openai-codex-responses (lines 73-77): Specialized provider for OpenAI Codex code-generation models
  • azure-openai-responses (lines 67-71): Connects to Azure-hosted OpenAI service deployments

Anthropic Claude

anthropic-messages (lines 42-47): Provides access to Anthropic's Claude chat models through the Messages API.

Google AI Platforms

  • google-generative-ai (lines 78-84): Connects to Google Gemini via the Generative AI API
  • google-vertex (lines 85-89): Supports Google Vertex AI for enterprise Gemini deployments

Mistral AI

mistral-conversations (lines 56-60): Implements streaming chat with Mistral-AI models.

Amazon Bedrock

bedrock-converse-stream (lines 90-95): Enables streaming conversations with Amazon Bedrock models, including Claude-like models hosted on AWS.

How to Configure API Keys

Prime Agent resolves API keys through environment variables mapped in packages/ai/src/env-api-keys.ts. The getEnvApiKey() function orchestrates lookup via findEnvKeys() and getApiKeyEnvVars() (lines 95-138).

Environment Variable Mappings

Provider Environment Variable
openai OPENAI_API_KEY
azure-openai-responses AZURE_OPENAI_API_KEY
google GEMINI_API_KEY
google-vertex GOOGLE_CLOUD_API_KEY
anthropic ANTHROPIC_OAUTH_TOKEN or ANTHROPIC_API_KEY
mistral MISTRAL_API_KEY
amazon-bedrock AWS credential chain (see below)

For OpenAI specifically, the provider reads process.env.OPENAI_API_KEY and throws an error if missing (see openai-responses.ts lines 177-182).

AWS Bedrock Configuration

Amazon Bedrock uses the AWS credential chain rather than a single API key. The system checks multiple sources including AWS_PROFILE, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_BEARER_TOKEN_BEDROCK (lines 87-108 in env-api-keys.ts).

Programmatic API Key Passing

You can bypass environment variables by passing an apiKey property in the options object. Most providers check options?.apiKey?.trim() first, as shown in google-vertex.ts line 407.

Configuration Examples

Set environment variables before launching:

export OPENAI_API_KEY="sk-your-openai-key"
export AZURE_OPENAI_API_KEY="your-azure-key"
export GEMINI_API_KEY="your-gemini-key"
export MISTRAL_API_KEY="your-mistral-key"
export ANTHROPIC_API_KEY="your-anthropic-key"
export GOOGLE_CLOUD_API_KEY="your-vertex-key"

Usage Code Examples

OpenAI Completions with Explicit Key

import { streamOpenAICompletions } from "@earendil-works/pi-ai";

const model = { 
  api: "openai-completions", 
  id: "gpt-4o-mini", 
  provider: "openai" 
};
const context = { 
  messages: [{ role: "user", content: "Write a haiku." }] 
};

for await (const event of streamOpenAICompletions(
  model, 
  context, 
  { apiKey: process.env.OPENAI_API_KEY }
)) {
  if (event.type === "text") console.log(event.text);
}

Amazon Bedrock with AWS Credentials

import { streamSimpleBedrockLazy as streamBedrock } from "@earendil-works/pi-ai";

const model = { 
  api: "bedrock-converse-stream", 
  id: "anthropic.claude-v2", 
  provider: "amazon-bedrock" 
};
const ctx = { 
  messages: [{ role: "user", content: "Summarize the latest news." }] 
};

for await (const ev of streamBedrock(model, ctx)) {
  if (ev.type === "text") console.log(ev.text);
}

Key Implementation Files

Summary

  • Prime Agent supports nine LLM providers via registerBuiltInApiProviders() in register-builtins.ts
  • API keys resolve through environment variables mapped in env-api-keys.ts
  • OpenAI, Anthropic, Google, Mistral, and Azure use specific *_API_KEY variables
  • Amazon Bedrock uses AWS credential chain variables instead of single keys
  • Pass apiKey in options objects to override environment variables

Frequently Asked Questions

Which environment variable does Prime Agent use for OpenAI?

Prime Agent checks OPENAI_API_KEY for OpenAI providers, as defined in packages/ai/src/env-api-keys.ts and accessed in openai-responses.ts lines 177-182.

Can I use Amazon Bedrock without explicit API keys?

Yes. Amazon Bedrock uses AWS credential chain variables such as AWS_PROFILE, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY rather than a single API key, as implemented in packages/ai/src/env-api-keys.ts lines 87-108.

How do I configure Google Vertex AI authentication?

Google Vertex AI supports either the GOOGLE_CLOUD_API_KEY environment variable or Application Default Credentials (ADC), with explicit keys taking precedence when passed via the apiKey options parameter (see google-vertex.ts line 407).

What happens if an API key is missing?

Prime Agent throws an error during provider initialization if a required environment variable is missing, as demonstrated in the OpenAI responses provider which validates process.env.OPENAI_API_KEY before making requests.

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 →