-
-
Notifications
You must be signed in to change notification settings - Fork 209
feat: add Mistral provider adapter for TanStack AI #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cstrnt
wants to merge
15
commits into
TanStack:main
Choose a base branch
from
cstrnt:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a87d242
feat: add Mistral provider adapter for TanStack AI
cstrnt 56da4e6
feat: implement Mistral text adapter with enhanced streaming and erro…
cstrnt ad3646e
Merge branch 'main' into main
AlemTuzlak 710f54b
Merge branch 'TanStack:main' into main
cstrnt 018ed5e
ci: apply automated fixes
autofix-ci[bot] 4cf5af5
Merge remote-tracking branch 'upstream/main'
cstrnt 23ad8e0
Merge branch 'main' into main
AlemTuzlak 325a627
fix(e2e): re-add @tanstack/ai-mistral dependency to package.json
cstrnt e7e418d
Merge remote-tracking branch 'upstream/main'
cstrnt ea0a367
refactor: reorder imports and simplify UUID generation in client utility
cstrnt 29d40df
ci: apply automated fixes
autofix-ci[bot] 0483637
fix(ai-mistral): CR loop fixes — data correctness, lifecycle, reasoning
AlemTuzlak e2e1d8c
ci: apply automated fixes
autofix-ci[bot] 8a157cc
ci: apply automated fixes (attempt 2/3)
autofix-ci[bot] 8210dad
Merge remote-tracking branch 'upstream/main'
cstrnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/ai-mistral': minor | ||
| --- | ||
|
|
||
| Add new `@tanstack/ai-mistral` adapter package for Mistral models using the `@mistralai/mistralai` SDK. Supports streaming chat, tool calling, vision input (Pixtral / Mistral Medium / Small), and structured output via JSON Schema. Includes model metadata for Mistral Large, Medium, Small, Ministral 3B/8B, Codestral, Pixtral, Magistral, and Open Mistral Nemo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # @tanstack/ai-mistral | ||
|
|
||
| Mistral adapter for TanStack AI. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @tanstack/ai-mistral | ||
| # or | ||
| pnpm add @tanstack/ai-mistral | ||
| # or | ||
| yarn add @tanstack/ai-mistral | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| Get your API key from [Mistral Console](https://console.mistral.ai/) and set it as an environment variable: | ||
|
|
||
| ```bash | ||
| export MISTRAL_API_KEY="..." | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Text/Chat Adapter | ||
|
|
||
| ```typescript | ||
| import { mistralText } from '@tanstack/ai-mistral' | ||
| import { generate } from '@tanstack/ai' | ||
|
|
||
| const adapter = mistralText('mistral-large-latest') | ||
|
|
||
| const result = await generate({ | ||
| adapter, | ||
| model: 'mistral-large-latest', | ||
| messages: [ | ||
| { role: 'user', content: 'Explain quantum computing in simple terms' }, | ||
| ], | ||
| }) | ||
|
|
||
| console.log(result.text) | ||
| ``` | ||
|
|
||
| ### With Explicit API Key | ||
|
|
||
| ```typescript | ||
| import { createMistralText } from '@tanstack/ai-mistral' | ||
|
|
||
| const adapter = createMistralText('mistral-large-latest', 'api_key') | ||
| ``` | ||
|
|
||
| ## Supported Models | ||
|
|
||
| ### Chat Models | ||
|
|
||
| - `mistral-large-latest` - Frontier flagship model (128k context) | ||
| - `mistral-medium-latest` - Balanced multimodal model (vision) | ||
| - `mistral-small-latest` - Fast, affordable multimodal model (vision) | ||
| - `ministral-8b-latest` - 8B edge model | ||
| - `ministral-3b-latest` - 3B edge model | ||
| - `codestral-latest` - Code-specialized model (256k context) | ||
| - `pixtral-large-latest` - Large vision model | ||
| - `pixtral-12b-2409` - 12B vision model | ||
| - `magistral-medium-latest` - Reasoning model | ||
| - `magistral-small-latest` - Small reasoning model | ||
| - `open-mistral-nemo` - Open 12B model | ||
|
|
||
| See [Mistral model comparison](https://docs.mistral.ai/getting-started/models/compare) for full details. | ||
|
|
||
| ## Features | ||
|
|
||
| - ✅ Streaming chat completions | ||
| - ✅ Structured output (JSON Schema) | ||
| - ✅ Function/tool calling | ||
| - ✅ Multimodal input (text + images for vision models) | ||
| - ❌ Embeddings (use the Mistral SDK directly) | ||
| - ❌ Image generation | ||
|
|
||
| ## Tree-Shakeable Adapters | ||
|
|
||
| This package uses tree-shakeable adapters, so you only import what you need: | ||
|
|
||
| ```typescript | ||
| import { mistralText } from '@tanstack/ai-mistral' | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| { | ||
| "name": "@tanstack/ai-mistral", | ||
| "version": "0.1.0", | ||
| "type": "module", | ||
| "description": "Mistral adapter for TanStack AI", | ||
| "author": "", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/TanStack/ai.git", | ||
| "directory": "packages/typescript/ai-mistral" | ||
| }, | ||
| "module": "./dist/esm/index.js", | ||
| "types": "./dist/esm/index.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/esm/index.d.ts", | ||
| "import": "./dist/esm/index.js" | ||
| }, | ||
| "./adapters/text": { | ||
| "types": "./dist/esm/adapters/text.d.ts", | ||
| "import": "./dist/esm/adapters/text.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "src" | ||
| ], | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "clean": "premove ./build ./dist", | ||
| "lint:fix": "eslint ./src --fix", | ||
| "test:build": "publint --strict", | ||
| "test:eslint": "eslint ./src", | ||
| "test:lib": "vitest run", | ||
| "test:lib:dev": "pnpm test:lib --watch", | ||
| "test:types": "tsc" | ||
| }, | ||
| "keywords": [ | ||
| "ai", | ||
| "mistral", | ||
| "tanstack", | ||
| "adapter" | ||
| ], | ||
| "devDependencies": { | ||
| "@vitest/coverage-v8": "4.0.14", | ||
| "vite": "^7.2.7" | ||
| }, | ||
| "peerDependencies": { | ||
| "@tanstack/ai": "workspace:^", | ||
| "zod": "^4.0.0" | ||
| }, | ||
| "dependencies": { | ||
| "@mistralai/mistralai": "^2.2.0" | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.