> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Provider Prefix Validation

> PraisonAIModel rejects unknown provider/model strings instead of silently routing to OpenAI

Point a CrewAI or AutoGen YAML at `mistral/mistral-small` without registering the provider, and PraisonAI tells you at startup instead of returning a confusing 404 from OpenAI.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    A[📋 model string] --> B{Has a slash?}
    B -->|no: gpt-4o-mini| O[✅ OpenAI]
    B -->|yes| C{Prefix known?}
    C -->|built-in| R[✅ Built-in route]
    C -->|registered| L[✅ Registered provider]
    C -->|unknown| D{Custom endpoint set?}
    D -->|yes| P[✅ Pass through unchanged]
    D -->|no| E[⛔ ValueError]

    classDef input fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef success fill:#10B981,stroke:#7C90A0,color:#fff
    classDef warn fill:#F59E0B,stroke:#7C90A0,color:#fff

    class A input
    class B,C,D process
    class O,R,L,P success
    class E warn
```

## Quick Start

**1. Built-in prefix works**

```yaml agents.yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: crewai
topic: Research
roles:
  researcher:
    role: Researcher
    goal: Summarise a topic
    backstory: You are a concise researcher.
    llm:
      model: groq/llama-3.3-70b-versatile
    tasks:
      summary:
        description: Summarise the history of the transistor.
        expected_output: Three sentences.
```

**2. Unknown prefix without an endpoint fails loudly**

Change the model to `mistral/mistral-small` with no endpoint configured:

```
ValueError: Unknown LLM provider prefix 'mistral' in model 'mistral/mistral-small'.
Use one of ['anthropic', 'cohere', 'google', 'groq', 'ollama', 'openai', 'openrouter'],
set base_url/OPENAI_API_BASE for an OpenAI-compatible endpoint, or register it via
praisonai.llm.register_llm_provider().
```

**3. Send it to an OpenAI-compatible endpoint**

Setting a custom endpoint passes slashed ids through unchanged — ideal for LiteLLM proxies, vLLM, and gateways.

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export OPENAI_API_BASE=http://localhost:4000/v1
praisonai agents.yaml
```

Or per role in YAML:

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    llm:
      model: meta-llama/Llama-3.1-8B
      base_url: http://localhost:8000/v1
```

**4. Or register the provider**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai.llm import register_llm_provider

class MistralProvider:
    provider_id = "mistral"

    def __init__(self, model_id, config=None):
        self.model_id = model_id
        self.config = config or {}

register_llm_provider("mistral", MistralProvider)
```

See [Custom Provider Registry](https://praison.ai/docs/models/custom-provider.md) for a full provider implementation.

***

## When does the error fire?

All three must be true:

1. The model string contains `/` — plain OpenAI ids such as `gpt-4o-mini` still default to OpenAI.
2. No custom endpoint is set — `base_url`, `OPENAI_API_BASE`, and `OPENAI_BASE_URL` are all unset.
3. The prefix is not built-in and not registered with `register_llm_provider(...)`.

### Built-in prefixes

| Prefix | Example |
| - | - |
| `openai` | `openai/gpt-4o-mini` |
| `groq` | `groq/llama-3.3-70b-versatile` |
| `cohere` | `cohere/command-r` |
| `ollama` | `ollama/llama3.2` |
| `anthropic` | `anthropic/claude-3-5-sonnet` |
| `google` | `google/gemini-2.0-flash` |
| `openrouter` | `openrouter/meta-llama/llama-3.1-8b-instruct` |

Prefixes already in the `praisonai.llm` registry (for example `vllm` or `lm_studio`) count as registered.

***

## Who this affects

| Entry point | Affected |
| - | - |
| `framework: crewai` YAML `llm.model` | ✅ Yes |
| `framework: autogen` YAML `llm.model` | ✅ Yes |
| Direct `PraisonAIModel(model=...)` in Python | ✅ Yes |
| `praisonaiagents.Agent(llm="mistral/...")` | ❌ No — routed through LiteLLM directly |

***

## Best Practices

> [accordion] Gateways: set the endpoint once
>
> If every model goes through one LiteLLM proxy, export `OPENAI_API_BASE` and keep the slashed ids as-is.

> [accordion] Native providers: register them
>
> For a provider with its own SDK (Bedrock, Mistral, Cloudflare), call `register_llm_provider` before running the YAML.

***

## Related

> [card] [Custom Provider Registry](https://praison.ai/docs/models/custom-provider.md)
>
> Register your own LLM providers

> [card] [CrewAI](https://praison.ai/docs/framework/crewai.md)
>
> Run CrewAI from PraisonAI YAML


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.