Namespace Conflict Pattern
Some auto-generated SDKs have their own IChatClient interface in the SDK namespace that shadows Microsoft.Extensions.AI.IChatClient. This causes compilation errors when trying to use MEAI interfaces directly.
Affected SDKs
| SDK | Has Conflict | Resolution |
|---|---|---|
| OpenAI | Yes | Use Meai alias |
| Mistral | Yes | Use Meai alias |
| Cohere | Yes | Use Meai alias |
| Together | Yes | Use Meai alias |
| Reka | Yes | Use Meai alias |
| Anthropic | No | Direct using works |
| Ollama | No | Direct using works |
| Google.Gemini | No | Direct using works |
| AI21 | No | Direct using works |
| HuggingFace | No | Direct using works |
| Jina | No | Direct using works |
| VoyageAI | No | Direct using works |
Common errors
Without the alias, you'll see errors like:
- CS0029: Cannot implicitly convert type
TogetherClienttoTogether.IChatClient - CS0308 / CS1929:
GetService<T>()resolves to the non-generic SDK method instead of the MEAI extension
The Meai alias pattern
Add a namespace alias at the top of your file:
1 | |
Then use the alias to explicitly reference MEAI types:
1 2 3 4 5 6 7 8 | |
Full example with Together
1 2 3 4 5 6 7 8 9 10 11 12 | |
Full example with IEmbeddingGenerator
The same pattern applies to IEmbeddingGenerator:
1 2 3 4 5 6 7 8 9 10 11 | |
SDKs without conflicts
For SDKs without namespace conflicts, you can use Microsoft.Extensions.AI directly:
1 2 3 4 5 6 | |