modAI supports multiple AI providers through a shared provider layer.
The provider layer allows the Manager to use AI capabilities without hard-coding provider-specific API behavior into user-facing workflows.
Current provider support includes:
- OpenAI
- Anthropic Claude
- Google Gemini
- OpenRouter
- Custom / OpenAI-compatible endpoints
Provider support may vary by capability and model.
| Capability | OpenAI | Anthropic Claude | Google Gemini | OpenRouter | Custom (OpenAI-compatible) |
|---|---|---|---|---|---|
| Chat / text generation | Yes | Yes | Yes | Yes | Yes |
| Streaming responses | Yes | Yes | Yes | Yes | Yes |
| Vision analysis | Yes | Yes | Yes | Yes | Yes |
| Image generation | Yes | No | Yes | Yes | Yes |
| Function calling (tools) | Yes | Yes | Yes | Yes¹ | Yes¹ |
| Text to audio (TTS) | Planned | — | Planned | Planned¹ | Planned¹ |
| Voice input (STT) | Planned | — | Planned | Planned¹ | Planned¹ |
Legend: Yes = supported today · Planned = on the roadmap, not yet implemented · — = not offered by the provider.
¹ Model-dependent. OpenRouter and custom endpoints route to many underlying models; vision, image, audio, and tool support depend on the selected model.
This matrix should be updated as provider support changes.
Embeddings, vector search, and RAG are provided through Context Providers, not through a provider-level embeddings capability. The built-in Pinecone provider relies on the vector database's own integrated embeddings rather than computing embeddings through an AI provider.
A provider is a PHP class implementing \modAI\Services\AIService. The key pieces:
getServiceName()returns a short identifier (e.g.openai) used to look up themodai.api.{service}.keysetting.isMyModel(string $model)claims a model prefix (e.g.openai/,anthropic/,custom/).AIServiceFactoryresolves aservice/modelstring by asking each registered service whether it owns that prefix.getCompletions()/getVision()/generateImage()build and return an\modAI\Services\Response\AIResponsedescribing the request (URL, headers, body, parser, streaming). modAI executes the request — the service does not call the HTTP API itself.
The five built-in services live in core/components/modai/src/Services/.
Each provider implementation should handle:
- Authentication (the
ApiKeytrait readsmodai.api.{service}.key) - Request formatting
- Response parsing (via the appropriate
AIResponseparser) - Model selection (the prefix claimed by
isMyModel()) - Capability support (text, vision, image)
- Provider-specific limits
- Provider-specific error handling
Provider-specific behavior should be documented.
A new provider should:
- Implement
\modAI\Services\AIService(use an existing service such asOpenRouteras a reference). - Claim a unique model prefix in
isMyModel()that does not collide with the built-ins (openai/,google/,anthropic/,openrouter/,custom/). - Register the class by returning it from a plugin on the
modAIOnServiceRegisterevent. - Add configuration fields for credentials and model settings.
- Document supported models and known limits.
- Include basic tests or manual test steps.
- Avoid changes to Manager UI unless the provider needs a new shared capability.
See the Supported Services docs for the contributor-facing details and a minimal service skeleton.
When adding a capability to an existing provider:
- Confirm that the provider supports the capability in the target models.
- Add support inside the provider implementation.
- Update the capability matrix.
- Add configuration notes if the feature requires a specific model or setting.
- Add tests or documented manual test steps.
Provider APIs differ.
Common differences include:
- Model names
- Token limits
- File and image formats
- Streaming formats
- Rate limits
- Safety filtering
- Error payloads
- Tool calling syntax
- Pricing models
Keep those differences inside the provider layer when possible.
Provider credentials should be handled with care.
Do not commit API keys or test credentials.
Documentation and examples should use placeholders.
Example:
YOUR_PROVIDER_API_KEY
When testing provider changes:
- Test with valid credentials.
- Test missing credentials.
- Test invalid credentials.
- Test provider rate limit or error responses where practical.
- Test unsupported model or capability combinations.
- Confirm the Manager shows a useful error.
Provider changes should update this file when they change:
- Supported providers
- Supported capabilities
- Configuration requirements
- Model requirements
- Known limitations