Newv2.0.1SDK โ€ข Go

Mistral Go SDK

A comprehensive Go SDK for the Mistral AI API with 100% feature parity with the official Python SDK (v1.9.11). Built with zero external dependencies using only Go's standard library for maximum compatibility, security, and performance.

๐ŸŽ‰ Major Milestone: Version 2.0.1 achieves 100% feature parity with the official Mistral Python SDK! Complete implementation of all 12 APIs with 100+ methods, 65.2% test coverage, A- security grade, and zero vulnerabilities.

๐Ÿ”ง v2.0.1 Critical Fix: Added User-Agent header to all HTTP requests to prevent Cloudflare 400 errors. This resolves issues when using the SDK directly or through proxies/gateways.

Key Features

100% Feature Parity

Complete parity with Mistral Python SDK v1.9.11. All 12 APIs, 100+ methods fully implemented.

Zero Dependencies

Built entirely with Go's standard library for maximum compatibility and security.

Chat Completions

Full-featured chat with streaming, tool calling, and all advanced parameters.

OCR & Audio

Document processing with OCR and speech-to-text transcription with timestamps.

Files & Fine-tuning

Complete file management and fine-tuning API for custom model training.

Beta Features

Conversations, Libraries, Documents, Accesses, and Mistral Agents APIs.

Quality Metrics

65.2% Test Coverage

Comprehensive test suite covering all major functionality and edge cases.

A- Security Grade

Zero security vulnerabilities. Comprehensive security audit passed.

Complete API Coverage

All 12 Mistral AI APIs fully implemented with 100+ methods:

Chat Completions
Chat Streaming
Embeddings
Fill-in-the-Middle (FIM)
Models API
Files API
Fine-tuning API
Batch API
Agents API
Classifiers API
OCR API
Audio/Transcriptions API

Quick Start

Installation

go get github.com/ZaguanLabs/mistral-go/v2/sdk

Basic Chat Completion

package main

import (
    "context"
    "fmt"
    "log"
    
    "github.com/ZaguanLabs/mistral-go/v2/sdk"
)

func main() {
    client := sdk.NewClient("your-api-key")
    
    response, err := client.Chat(context.Background(), &sdk.ChatRequest{
        Model: "mistral-large-latest",
        Messages: []sdk.Message{
            {Role: "user", Content: "Hello, Mistral!"},
        },
    })
    
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Println(response.Choices[0].Message.Content)
}

Streaming Responses

stream, err := client.ChatStream(context.Background(), &sdk.ChatRequest{
    Model: "mistral-large-latest",
    Messages: []sdk.Message{
        {Role: "user", Content: "Tell me a story"},
    },
})

if err != nil {
    log.Fatal(err)
}
defer stream.Close()

for {
    chunk, err := stream.Recv()
    if err == io.EOF {
        break
    }
    if err != nil {
        log.Fatal(err)
    }
    fmt.Print(chunk.Choices[0].Delta.Content)
}

Recent Updates

v2.0.1 - Latest2025-11-20

Critical Fix

  • User-Agent Header: Added to all HTTP requests to prevent Cloudflare 400 errors
  • Cloudflare Compatibility: Cloudflare-protected endpoints now work correctly
  • Test Coverage: Added comprehensive tests to prevent regression
  • Proxy Support: Resolves issues when using SDK through proxies/gateways

Version 2.0.0 Highlights

Major milestone release achieving 100% feature parity with the official Mistral Python SDK!

  • Complete Models API: All CRUD operations including retrieve, delete, update, archive/unarchive
  • Enhanced Embeddings: Full parameter support with encoding formats and output dimensions
  • FIM Streaming: Streaming support for code completions
  • OCR API: Complete document processing with page selection and bounding boxes
  • Audio API: Speech-to-text with word and segment-level timestamps
  • Beta Features: Conversations, Libraries, Documents, Accesses, and Mistral Agents
  • Zero Dependencies: Pure Go implementation using only standard library
  • Security: A- grade with 0 vulnerabilities

See the full CHANGELOG.md for complete details.

Acknowledgments

Huge thanks to Gage Technologies for creating the initial version of this SDK! ๐Ÿ™

This project builds upon their excellent foundation from the original repository. We're grateful for their pioneering work in bringing Mistral AI capabilities to the Go ecosystem.

MIT Licensed - The Mistral Go SDK is free and open source software. You're welcome to use, modify, and distribute it for any purpose.

Get Started Today

Version 2.0.0 with 100% feature parity is available now. Star the repository on GitHub to follow updates.