MCPAgent supports OpenAI, Anthropic, Google, OpenRouter, Ollama, and OpenAI-compatible endpoints. Configure a provider with a "provider/model" string or a ProviderConfig.
Choose a provider
Configure a provider string
Set the provider’s environment variable before starting the process. The agent resolves the key when it initializes./. For example, openrouter/openai/gpt-4o selects the openrouter provider and passes openai/gpt-4o as the model name.
Connect an OpenAI-compatible endpoint
Useopenai-compatible for an endpoint that implements OpenAI chat-completions semantics. Supply the full API base URL and any required headers.
Handle configuration errors
Initialization throws when:- a provider string is not in
provider/modelform; - the provider prefix is unsupported;
- a required API key is missing; or
- no model driver can be created.
llmConfig or ProviderConfig. See the MCPAgent API reference for the complete option types.