Skip to content

feat: Add Mistral AI provider support#246

Open
Esashiero wants to merge 1 commit intosipeed:mainfrom
Esashiero:mistral-support
Open

feat: Add Mistral AI provider support#246
Esashiero wants to merge 1 commit intosipeed:mainfrom
Esashiero:mistral-support

Conversation

@Esashiero
Copy link

Summary

This PR adds Mistral AI as a supported LLM provider in PicoClaw.

Changes

  1. Uses /v1/conversations API endpoint - Different rate limits than chat completions, accepts "latest" model names

  2. Request format conversion:

    • messagesinputs
    • System prompts → instructions field
    • max_tokens, temperaturecompletion_args
  3. Tool support:

    • Uses Mistral's built-in web_search tool
    • Converts tool results to user messages for feedback loop
  4. Response parsing:

    • Handles array content format when tools are used
    • Parses tool execution outputs

Usage

{
  "agents": {
    "defaults": {
      "provider": "mistral",
      "model": "mistral-large-latest"
    }
  },
  "providers": {
    "mistral": {
      "api_key": "your-mistral-api-key"
    }
  }
}

Testing

  • Simple queries work (no tools)
  • Web search queries work (with tools) - full flow verified

- Use /v1/conversations API endpoint (different rate limits)
- Convert messages to inputs format for Mistral API
- Handle system prompts via instructions field
- Support Mistral built-in web_search tool
- Convert tool results to user messages for feedback loop
- Parse response with array content format

Closes #<issue>
@Leeaandrob
Copy link
Collaborator

@Zepan Mistral AI is a good provider to support. However, PR #213 (Provider Refactor — roadmap #283, In Progress) will restructure how providers are organized.

Recommendation: Wait for #213 to merge first. The refactor groups providers by protocol (OpenAI-compatible, Anthropic, etc.) — Mistral would likely fit into the OpenAI-compatible family, making this PR much simpler after the refactor.

@yinwm
Copy link
Collaborator

yinwm commented Feb 20, 2026

Thanks for the contribution! This PR adds valuable Mistral-specific features (native /v1/conversations endpoint, built-in web_search).

However, this PR needs to be reworked due to recent architecture changes.

Architecture Update:

PR #492 (Provider Refactoring) has been merged on 2026-02-20, introducing a protocol-based model_list configuration. See the design doc: provider-refactoring.md

Current Status:

Mistral is not yet registered as a protocol. However, users can already use Mistral via OpenAI-compatible API:

{
  "model_list": [
    {
      "model_name": "mistral",
      "model": "openai/mistral-large-latest",
      "api_base": "https://api.mistral.ai/v1",
      "api_key": "your-key"
    }
  ]
}

Suggested Implementation for Native Mistral API:

To add native /v1/conversations support with web_search, please rebase and restructure as follows:

  1. Create pkg/providers/mistral/provider.go:

    • Implement MistralProvider struct with Chat() method
    • Handle /v1/conversations endpoint
    • Convert message format: messagesinputs, system prompt → instructions
    • Support built-in web_search tool
  2. Register protocol in pkg/providers/factory_provider.go:

    case "mistral":
        apiBase := cfg.APIBase
        if apiBase == "" {
            apiBase = "https://api.mistral.ai/v1"
        }
        return NewMistralProvider(cfg.APIKey, apiBase), modelID, nil

    Also add to getDefaultAPIBase():

    case "mistral":
        return "https://api.mistral.ai/v1"
  3. Example configuration:

    {
      "model_list": [
        {
          "model_name": "my-mistral",
          "model": "mistral/mistral-large-latest",
          "api_key": "your-key"
        }
      ]
    }

You can refer to pkg/providers/anthropic/provider.go as a reference for the structure.

Would you like to rebase and update this PR with the new approach? Happy to help review once updated!

@nikolasdehor
Copy link

PR #541 implements native Mistral AI provider support, which addresses this feature request. Linking for visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants