Skip to content

[Tier 3] Add model provider abstraction (Azure, Anthropic, Ollama) #16

Description

@justsml

Problem

Model resolution in src/mastra/config/model.ts hardcodes createOpenAI with an OpenRouter base URL. This locks out users who want to use Azure OpenAI, Anthropic direct, local Ollama, or other providers. The llm:// URI scheme is designed for provider abstraction, but the runtime doesn't fully utilize it.

Goal

Support multiple model providers via the existing llm:// URI scheme using llm-strings for provider-specific adapter creation.

Acceptance Criteria

  • Audit src/mastra/config/model.ts for hardcoded OpenRouter assumptions
  • Use llm-strings to resolve provider from URI (openrouter, azure, anthropic, ollama, etc.)
  • Create provider-specific AI SDK adapters:
    • OpenRouter (existing, via @ai-sdk/openai with custom baseURL)
    • Azure OpenAI (via @ai-sdk/azure)
    • Anthropic direct (via @ai-sdk/anthropic)
    • Ollama local (via @ai-sdk/ollama or OpenAI-compatible)
  • Add provider-specific env var templates to .env.example
  • Document supported providers in README
  • Add at least one test per provider path
  • Ensure fallback behavior if a provider package is not installed

Context

  • llm-strings already exports parse, normalize, and build functions
  • AGENTS.md says: "Use llm-strings directly at adapter boundaries: parse for model/host, normalize for canonical generation params, build for connection strings"
  • The .env.example already has placeholders for alternate model providers

Labels

infrastructure, tier-3-virality-polish, help wanted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions