Documentation
¶
Overview ¶
Package mistral provides an idiomatic Go client for the Mistral AI API.
Create a client with your API key, then call methods for each endpoint:
client := mistral.NewClient("sk-...")
// Chat completion
resp, err := client.ChatComplete(ctx, &chat.CompletionRequest{
Model: "mistral-small-latest",
Messages: []chat.Message{&chat.UserMessage{Content: chat.TextContent("Hello!")}},
})
// Streaming
stream, err := client.ChatCompleteStream(ctx, req)
defer stream.Close()
for stream.Next() {
chunk := stream.Current()
fmt.Print(chunk.Choices[0].Delta.Content)
}
Configuration ¶
Use functional options to configure the client:
client := mistral.NewClient("sk-...",
mistral.WithTimeout(30 * time.Second),
mistral.WithRetry(3, 500*time.Millisecond),
)
Error Handling ¶
API errors are returned as *APIError values. Use sentinel checkers for common cases:
if mistral.IsRateLimit(err) {
// back off and retry
}
Sub-packages ¶
Types are organized into sub-packages by domain: chat, agents, connector, conversation, embedding, model, file, finetune, batch, ocr, audio, library, moderation, classification, fim, and observability. All service methods live directly on Client.
Reference ¶
This SDK tracks the official Mistral Python SDK (https://github.com/mistralai/client-python) as its upstream reference for API surface and type definitions.
Index ¶
- Constants
- func IsAuth(err error) bool
- func IsNotFound(err error) bool
- func IsRateLimit(err error) bool
- type APIError
- type AudioStream
- type Client
- func (c *Client) AgentsComplete(ctx context.Context, req *agents.CompletionRequest) (*chat.CompletionResponse, error)
- func (c *Client) AgentsCompleteStream(ctx context.Context, req *agents.CompletionRequest) (*Stream[chat.CompletionChunk], error)
- func (c *Client) AppendConversation(ctx context.Context, conversationID string, req *conversation.AppendRequest) (*conversation.Response, error)
- func (c *Client) AppendConversationStream(ctx context.Context, conversationID string, req *conversation.AppendRequest) (*EventStream, error)
- func (c *Client) ArchiveFineTunedModel(ctx context.Context, modelID string) (*finetune.ArchiveFTModelOut, error)
- func (c *Client) ArchiveWorkflow(ctx context.Context, workflowIdentifier string) (*workflow.WorkflowArchiveResponse, error)
- func (c *Client) BatchCancelWorkflowExecutions(ctx context.Context, req *workflow.BatchExecutionBody) (*workflow.BatchExecutionResponse, error)
- func (c *Client) BatchTerminateWorkflowExecutions(ctx context.Context, req *workflow.BatchExecutionBody) (*workflow.BatchExecutionResponse, error)
- func (c *Client) BulkDeleteDatasetRecords(ctx context.Context, req *observability.BulkDeleteRecordsRequest) error
- func (c *Client) CallConnectorTool(ctx context.Context, idOrName, toolName string, req *connector.CallToolRequest) (*connector.CallToolResponse, error)
- func (c *Client) CancelBatchJob(ctx context.Context, jobID string) (*batch.JobOut, error)
- func (c *Client) CancelFineTuningJob(ctx context.Context, jobID string) (*finetune.JobOut, error)
- func (c *Client) CancelWorkflowExecution(ctx context.Context, executionID string) error
- func (c *Client) ChatComplete(ctx context.Context, req *chat.CompletionRequest) (*chat.CompletionResponse, error)
- func (c *Client) ChatCompleteStream(ctx context.Context, req *chat.CompletionRequest) (*Stream[chat.CompletionChunk], error)
- func (c *Client) Classify(ctx context.Context, req *classification.Request) (*classification.Response, error)
- func (c *Client) ClassifyChat(ctx context.Context, req *classification.ChatRequest) (*classification.Response, error)
- func (c *Client) CreateAgent(ctx context.Context, req *agents.CreateRequest) (*agents.Agent, error)
- func (c *Client) CreateBatchJob(ctx context.Context, req *batch.JobIn) (*batch.JobOut, error)
- func (c *Client) CreateCampaign(ctx context.Context, req *observability.CreateCampaignRequest) (*observability.Campaign, error)
- func (c *Client) CreateConnector(ctx context.Context, req *connector.CreateRequest) (*connector.Connector, error)
- func (c *Client) CreateDataset(ctx context.Context, req *observability.CreateDatasetRequest) (*observability.Dataset, error)
- func (c *Client) CreateDatasetRecord(ctx context.Context, datasetID string, req *observability.CreateRecordRequest) (*observability.DatasetRecord, error)
- func (c *Client) CreateEmbeddings(ctx context.Context, req *embedding.Request) (*embedding.Response, error)
- func (c *Client) CreateFineTuningJob(ctx context.Context, req *finetune.JobIn) (*finetune.JobOut, error)
- func (c *Client) CreateJudge(ctx context.Context, req *observability.CreateJudgeRequest) (*observability.Judge, error)
- func (c *Client) CreateLibrary(ctx context.Context, req *library.CreateRequest) (*library.Library, error)
- func (c *Client) CreateVoice(ctx context.Context, req *audio.VoiceCreateRequest) (*audio.VoiceResponse, error)
- func (c *Client) DeleteAgent(ctx context.Context, agentID string) error
- func (c *Client) DeleteAgentAlias(ctx context.Context, agentID string, alias string) error
- func (c *Client) DeleteBatchJob(ctx context.Context, jobID string) (*batch.DeleteResponse, error)
- func (c *Client) DeleteCampaign(ctx context.Context, campaignID string) error
- func (c *Client) DeleteConnector(ctx context.Context, idOrName string) error
- func (c *Client) DeleteConversation(ctx context.Context, conversationID string) error
- func (c *Client) DeleteDataset(ctx context.Context, datasetID string) error
- func (c *Client) DeleteDatasetRecord(ctx context.Context, recordID string) error
- func (c *Client) DeleteDocument(ctx context.Context, libraryID, documentID string) error
- func (c *Client) DeleteFile(ctx context.Context, fileID string) (*file.DeleteResponse, error)
- func (c *Client) DeleteJudge(ctx context.Context, judgeID string) error
- func (c *Client) DeleteLibrary(ctx context.Context, libraryID string) (*library.Library, error)
- func (c *Client) DeleteModel(ctx context.Context, modelID string) (*model.DeleteModelOut, error)
- func (c *Client) DeleteVoice(ctx context.Context, voiceID string) error
- func (c *Client) ExecuteWorkflow(ctx context.Context, workflowIdentifier string, req *workflow.ExecutionRequest) (*workflow.ExecutionResponse, error)
- func (c *Client) ExecuteWorkflowAndWait(ctx context.Context, workflowIdentifier string, req *workflow.ExecutionRequest) (*workflow.ExecutionResponse, error)
- func (c *Client) ExecuteWorkflowRegistration(ctx context.Context, registrationID string, req *workflow.ExecutionRequest) (*workflow.ExecutionResponse, error)deprecated
- func (c *Client) ExportDatasetToJSONL(ctx context.Context, datasetID string) (*observability.ExportDatasetResponse, error)
- func (c *Client) FIMComplete(ctx context.Context, req *fim.CompletionRequest) (*chat.CompletionResponse, error)
- func (c *Client) FIMCompleteStream(ctx context.Context, req *fim.CompletionRequest) (*Stream[chat.CompletionChunk], error)
- func (c *Client) GetAgent(ctx context.Context, agentID string) (*agents.Agent, error)
- func (c *Client) GetAgentVersion(ctx context.Context, agentID string, version string) (*agents.Agent, error)
- func (c *Client) GetBatchJob(ctx context.Context, jobID string) (*batch.JobOut, error)
- func (c *Client) GetCampaign(ctx context.Context, campaignID string) (*observability.Campaign, error)
- func (c *Client) GetCampaignStatus(ctx context.Context, campaignID string) (*observability.CampaignStatusResponse, error)
- func (c *Client) GetChatCompletionEvent(ctx context.Context, eventID string) (*observability.ChatCompletionEvent, error)
- func (c *Client) GetChatCompletionFieldOptions(ctx context.Context, fieldName string, operator observability.FieldOperator) (*observability.ChatCompletionFieldOptions, error)
- func (c *Client) GetChatCompletionFieldOptionsCounts(ctx context.Context, fieldName string, ...) (*observability.FieldOptionCounts, error)
- func (c *Client) GetChatCompletionFields(ctx context.Context) (*observability.ChatCompletionFields, error)
- func (c *Client) GetConnector(ctx context.Context, idOrName string) (*connector.Connector, error)
- func (c *Client) GetConnectorAuthURL(ctx context.Context, idOrName string, appReturnURL *string) (*connector.AuthURLResponse, error)
- func (c *Client) GetConversation(ctx context.Context, conversationID string) (*conversation.Conversation, error)
- func (c *Client) GetConversationHistory(ctx context.Context, conversationID string) (*conversation.History, error)
- func (c *Client) GetConversationMessages(ctx context.Context, conversationID string) (*conversation.Messages, error)
- func (c *Client) GetDataset(ctx context.Context, datasetID string) (*observability.Dataset, error)
- func (c *Client) GetDatasetRecord(ctx context.Context, recordID string) (*observability.DatasetRecord, error)
- func (c *Client) GetDatasetTask(ctx context.Context, datasetID, taskID string) (*observability.DatasetImportTask, error)
- func (c *Client) GetDocument(ctx context.Context, libraryID, documentID string) (*library.Document, error)
- func (c *Client) GetDocumentExtractedTextSignedURL(ctx context.Context, libraryID, documentID string) (string, error)
- func (c *Client) GetDocumentSignedURL(ctx context.Context, libraryID, documentID string) (string, error)
- func (c *Client) GetDocumentStatus(ctx context.Context, libraryID, documentID string) (*library.ProcessingStatusOut, error)
- func (c *Client) GetDocumentTextContent(ctx context.Context, libraryID, documentID string) (*library.DocumentTextContent, error)
- func (c *Client) GetFile(ctx context.Context, fileID string) (*file.File, error)
- func (c *Client) GetFileContent(ctx context.Context, fileID string) (io.ReadCloser, error)
- func (c *Client) GetFileURL(ctx context.Context, fileID string, expiryHours int) (*file.SignedURL, error)
- func (c *Client) GetFineTuningJob(ctx context.Context, jobID string) (*finetune.JobOut, error)
- func (c *Client) GetJudge(ctx context.Context, judgeID string) (*observability.Judge, error)
- func (c *Client) GetLibrary(ctx context.Context, libraryID string) (*library.Library, error)
- func (c *Client) GetModel(ctx context.Context, modelID string) (*model.ModelCard, error)
- func (c *Client) GetSimilarChatCompletionEvents(ctx context.Context, eventID string, params *observability.PaginationParams) (*observability.SimilarEventsResponse, error)
- func (c *Client) GetVoice(ctx context.Context, voiceID string) (*audio.VoiceResponse, error)
- func (c *Client) GetVoiceSampleAudio(ctx context.Context, voiceID string) (*http.Response, error)
- func (c *Client) GetWorkflow(ctx context.Context, workflowIdentifier string) (*workflow.Workflow, error)
- func (c *Client) GetWorkflowDeployment(ctx context.Context, deploymentID string) (*workflow.Deployment, error)
- func (c *Client) GetWorkflowExecution(ctx context.Context, executionID string) (*workflow.ExecutionResponse, error)
- func (c *Client) GetWorkflowExecutionHistory(ctx context.Context, executionID string, decodePayloads *bool) (json.RawMessage, error)
- func (c *Client) GetWorkflowExecutionTraceEvents(ctx context.Context, executionID string, params *workflow.TraceEventsParams) (*workflow.TraceEventsResponse, error)
- func (c *Client) GetWorkflowExecutionTraceOTel(ctx context.Context, executionID string) (*workflow.TraceOTelResponse, error)
- func (c *Client) GetWorkflowExecutionTraceSummary(ctx context.Context, executionID string) (*workflow.TraceSummaryResponse, error)
- func (c *Client) GetWorkflowMetrics(ctx context.Context, workflowName string, params *workflow.MetricsParams) (*workflow.Metrics, error)
- func (c *Client) GetWorkflowRegistration(ctx context.Context, registrationID string, ...) (*workflow.Registration, error)
- func (c *Client) GetWorkflowRun(ctx context.Context, runID string) (*workflow.Run, error)
- func (c *Client) GetWorkflowRunHistory(ctx context.Context, runID string) (json.RawMessage, error)
- func (c *Client) GetWorkflowWorkerInfo(ctx context.Context) (*workflow.WorkerInfo, error)
- func (c *Client) ImportDatasetFromCampaign(ctx context.Context, datasetID string, ...) (*observability.DatasetImportTask, error)
- func (c *Client) ImportDatasetFromDataset(ctx context.Context, datasetID string, ...) (*observability.DatasetImportTask, error)
- func (c *Client) ImportDatasetFromExplorer(ctx context.Context, datasetID string, ...) (*observability.DatasetImportTask, error)
- func (c *Client) ImportDatasetFromFile(ctx context.Context, datasetID string, ...) (*observability.DatasetImportTask, error)
- func (c *Client) ImportDatasetFromPlayground(ctx context.Context, datasetID string, ...) (*observability.DatasetImportTask, error)
- func (c *Client) JudgeChatCompletionEvent(ctx context.Context, eventID string, req *observability.JudgeEventRequest) (json.RawMessage, error)
- func (c *Client) JudgeConversation(ctx context.Context, judgeID string, ...) (json.RawMessage, error)
- func (c *Client) JudgeDatasetRecord(ctx context.Context, recordID string, req *observability.JudgeRecordRequest) (json.RawMessage, error)
- func (c *Client) ListAgentAliases(ctx context.Context, agentID string) ([]agents.AliasResponse, error)
- func (c *Client) ListAgentVersions(ctx context.Context, agentID string, params *agents.ListVersionsParams) ([]agents.Agent, error)
- func (c *Client) ListAgents(ctx context.Context, params *agents.ListParams) ([]agents.Agent, error)
- func (c *Client) ListBatchJobs(ctx context.Context, params *batch.ListParams) (*batch.JobsOut, error)
- func (c *Client) ListCampaignEvents(ctx context.Context, campaignID string, params *observability.PaginationParams) (*observability.ListCampaignEventsResponse, error)
- func (c *Client) ListCampaigns(ctx context.Context, params *observability.SearchParams) (*observability.ListCampaignsResponse, error)
- func (c *Client) ListConnectorTools(ctx context.Context, idOrName string, params *connector.ListToolsParams) ([]connector.Tool, error)
- func (c *Client) ListConnectors(ctx context.Context, params *connector.ListParams) ([]connector.Connector, error)
- func (c *Client) ListConversations(ctx context.Context, params *conversation.ListParams) ([]conversation.Conversation, error)
- func (c *Client) ListDatasetRecords(ctx context.Context, datasetID string, params *observability.PaginationParams) (*observability.ListRecordsResponse, error)
- func (c *Client) ListDatasetTasks(ctx context.Context, datasetID string, params *observability.PaginationParams) (*observability.ListTasksResponse, error)
- func (c *Client) ListDatasets(ctx context.Context, params *observability.SearchParams) (*observability.ListDatasetsResponse, error)
- func (c *Client) ListDocuments(ctx context.Context, libraryID string, params *library.ListDocumentParams) (*library.ListDocumentOut, error)
- func (c *Client) ListFiles(ctx context.Context, params *file.ListParams) (*file.ListResponse, error)
- func (c *Client) ListFineTuningJobs(ctx context.Context, params *finetune.ListParams) (*finetune.JobsOut, error)
- func (c *Client) ListJudges(ctx context.Context, params *observability.SearchParams) (*observability.ListJudgesResponse, error)
- func (c *Client) ListLibraries(ctx context.Context, params *library.ListLibraryParams) (*library.ListLibraryOut, error)
- func (c *Client) ListLibrarySharing(ctx context.Context, libraryID string) (*library.ListSharingOut, error)
- func (c *Client) ListModels(ctx context.Context, params *model.ListParams) (*model.ModelList, error)
- func (c *Client) ListVoices(ctx context.Context) (*audio.VoiceListResponse, error)
- func (c *Client) ListWorkflowDeployments(ctx context.Context, params *workflow.DeploymentListParams) (*workflow.DeploymentListResponse, error)
- func (c *Client) ListWorkflowEvents(ctx context.Context, params *workflow.EventListParams) (*workflow.EventListResponse, error)
- func (c *Client) ListWorkflowRegistrations(ctx context.Context, params *workflow.RegistrationListParams) (*workflow.RegistrationListResponse, error)
- func (c *Client) ListWorkflowRuns(ctx context.Context, params *workflow.RunListParams) (*workflow.ListRunsResponse, error)
- func (c *Client) ListWorkflowSchedules(ctx context.Context) (*workflow.ScheduleListResponse, error)
- func (c *Client) ListWorkflows(ctx context.Context, params *workflow.WorkflowListParams) (*workflow.WorkflowListResponse, error)
- func (c *Client) Moderate(ctx context.Context, req *moderation.Request) (*moderation.Response, error)
- func (c *Client) ModerateChat(ctx context.Context, req *moderation.ChatRequest) (*moderation.Response, error)
- func (c *Client) OCR(ctx context.Context, req *ocr.Request) (*ocr.Response, error)
- func (c *Client) QueryWorkflowExecution(ctx context.Context, executionID string, req *workflow.QueryInvocationBody) (*workflow.QueryResponse, error)
- func (c *Client) ReprocessDocument(ctx context.Context, libraryID, documentID string) error
- func (c *Client) ResetWorkflowExecution(ctx context.Context, executionID string, req *workflow.ResetInvocationBody) error
- func (c *Client) RestartConversation(ctx context.Context, conversationID string, req *conversation.RestartRequest) (*conversation.Response, error)
- func (c *Client) RestartConversationStream(ctx context.Context, conversationID string, req *conversation.RestartRequest) (*EventStream, error)
- func (c *Client) ScheduleWorkflow(ctx context.Context, req *workflow.ScheduleRequest) (*workflow.ScheduleResponse, error)
- func (c *Client) SearchChatCompletionEventIDs(ctx context.Context, req *observability.SearchEventIDsRequest) (*observability.SearchEventIDsResponse, error)
- func (c *Client) SearchChatCompletionEvents(ctx context.Context, req *observability.SearchEventsRequest) (*observability.SearchEventsResponse, error)
- func (c *Client) SetAgentAlias(ctx context.Context, agentID string, alias string, version int) (*agents.AliasResponse, error)
- func (c *Client) ShareLibrary(ctx context.Context, libraryID string, req *library.SharingRequest) (*library.SharingOut, error)
- func (c *Client) SignalWorkflowExecution(ctx context.Context, executionID string, req *workflow.SignalInvocationBody) (*workflow.SignalResponse, error)
- func (c *Client) Speech(ctx context.Context, req *audio.SpeechRequest) (*audio.SpeechResponse, error)
- func (c *Client) SpeechStream(ctx context.Context, req *audio.SpeechRequest) (*SpeechStream, error)
- func (c *Client) StartConversation(ctx context.Context, req *conversation.StartRequest) (*conversation.Response, error)
- func (c *Client) StartConversationStream(ctx context.Context, req *conversation.StartRequest) (*EventStream, error)
- func (c *Client) StartFineTuningJob(ctx context.Context, jobID string) (*finetune.JobOut, error)
- func (c *Client) StreamWorkflowEvents(ctx context.Context, params *workflow.EventStreamParams) (*WorkflowEventStream, error)
- func (c *Client) StreamWorkflowExecution(ctx context.Context, executionID string, params *workflow.StreamParams) (*WorkflowEventStream, error)
- func (c *Client) TerminateWorkflowExecution(ctx context.Context, executionID string) error
- func (c *Client) Transcribe(ctx context.Context, req *audio.TranscriptionRequest, filename string, ...) (*audio.TranscriptionResponse, error)
- func (c *Client) TranscribeStream(ctx context.Context, req *audio.TranscriptionRequest, filename string, ...) (*AudioStream, error)
- func (c *Client) UnarchiveFineTunedModel(ctx context.Context, modelID string) (*finetune.UnarchiveFTModelOut, error)
- func (c *Client) UnarchiveWorkflow(ctx context.Context, workflowIdentifier string) (*workflow.WorkflowArchiveResponse, error)
- func (c *Client) UnscheduleWorkflow(ctx context.Context, scheduleID string) error
- func (c *Client) UnshareLibrary(ctx context.Context, libraryID string, req *library.SharingDeleteRequest) (*library.SharingOut, error)
- func (c *Client) UpdateAgent(ctx context.Context, agentID string, req *agents.UpdateRequest) (*agents.Agent, error)
- func (c *Client) UpdateAgentVersion(ctx context.Context, agentID string, version int) (*agents.Agent, error)
- func (c *Client) UpdateConnector(ctx context.Context, idOrName string, req *connector.UpdateRequest) (*connector.Connector, error)
- func (c *Client) UpdateDataset(ctx context.Context, datasetID string, req *observability.UpdateDatasetRequest) (*observability.Dataset, error)
- func (c *Client) UpdateDatasetRecordPayload(ctx context.Context, recordID string, ...) (*observability.DatasetRecord, error)
- func (c *Client) UpdateDatasetRecordProperties(ctx context.Context, recordID string, ...) (*observability.DatasetRecord, error)
- func (c *Client) UpdateDocument(ctx context.Context, libraryID, documentID string, ...) (*library.Document, error)
- func (c *Client) UpdateFineTunedModel(ctx context.Context, modelID string, req *finetune.UpdateFTModelIn) (json.RawMessage, error)
- func (c *Client) UpdateJudge(ctx context.Context, judgeID string, req *observability.UpdateJudgeRequest) (*observability.Judge, error)
- func (c *Client) UpdateLibrary(ctx context.Context, libraryID string, req *library.UpdateRequest) (*library.Library, error)
- func (c *Client) UpdateVoice(ctx context.Context, voiceID string, req *audio.VoiceUpdateRequest) (*audio.VoiceResponse, error)
- func (c *Client) UpdateWorkflow(ctx context.Context, workflowIdentifier string, ...) (*workflow.Workflow, error)
- func (c *Client) UpdateWorkflowExecution(ctx context.Context, executionID string, req *workflow.UpdateInvocationBody) (*workflow.UpdateResponse, error)
- func (c *Client) UploadDocument(ctx context.Context, libraryID string, filename string, file io.Reader) (*library.Document, error)
- func (c *Client) UploadFile(ctx context.Context, filename string, r io.Reader, params *file.UploadParams) (*file.File, error)
- type EventStream
- type Option
- type SpeechStream
- type Stream
- type WorkflowEventStream
Examples ¶
Constants ¶
const Version = "1.3.0"
Version is the SDK version string.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound returns true if the error is a 404 Not Found error.
Example ¶
package main
import (
"context"
"fmt"
mistral "github.com/VikingOwl91/mistral-go-sdk"
)
func main() {
client := mistral.NewClient("sk-your-api-key")
_, err := client.GetModel(context.Background(), "nonexistent-model")
if mistral.IsNotFound(err) {
fmt.Println("Model not found")
}
}
Output:
func IsRateLimit ¶
IsRateLimit returns true if the error is a 429 Too Many Requests error.
Example ¶
package main
import (
"context"
"fmt"
mistral "github.com/VikingOwl91/mistral-go-sdk"
"github.com/VikingOwl91/mistral-go-sdk/chat"
)
func main() {
client := mistral.NewClient("sk-your-api-key")
_, err := client.ChatComplete(context.Background(), &chat.CompletionRequest{
Model: "mistral-small-latest",
Messages: []chat.Message{
&chat.UserMessage{Content: chat.TextContent("Hi")},
},
})
if mistral.IsRateLimit(err) {
fmt.Println("Rate limited — back off and retry")
}
}
Output:
Types ¶
type APIError ¶
type APIError struct {
StatusCode int `json:"-"`
Type string `json:"type,omitempty"`
Message string `json:"message"`
Param string `json:"param,omitempty"`
Code string `json:"code,omitempty"`
}
APIError represents an error response from the Mistral API.
type AudioStream ¶
type AudioStream struct {
// contains filtered or unexported fields
}
AudioStream wraps the generic Stream to provide typed audio events.
func (*AudioStream) Close ¶
func (s *AudioStream) Close() error
Close releases the underlying connection.
func (*AudioStream) Current ¶
func (s *AudioStream) Current() audio.StreamEvent
Current returns the most recently read event.
func (*AudioStream) Err ¶
func (s *AudioStream) Err() error
Err returns any error encountered during streaming.
func (*AudioStream) Next ¶
func (s *AudioStream) Next() bool
Next advances to the next event. Returns false when done or on error.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Mistral AI API client.
func NewClient ¶
NewClient creates a new Mistral AI client with the given API key.
Example ¶
package main
import (
mistral "github.com/VikingOwl91/mistral-go-sdk"
)
func main() {
client := mistral.NewClient("sk-your-api-key")
_ = client // use client to call API methods
}
Output:
func (*Client) AgentsComplete ¶
func (c *Client) AgentsComplete(ctx context.Context, req *agents.CompletionRequest) (*chat.CompletionResponse, error)
AgentsComplete sends an agents completion request.
func (*Client) AgentsCompleteStream ¶
func (c *Client) AgentsCompleteStream(ctx context.Context, req *agents.CompletionRequest) (*Stream[chat.CompletionChunk], error)
AgentsCompleteStream sends an agents request and returns a stream of chunks.
func (*Client) AppendConversation ¶
func (c *Client) AppendConversation(ctx context.Context, conversationID string, req *conversation.AppendRequest) (*conversation.Response, error)
AppendConversation appends inputs to an existing conversation.
func (*Client) AppendConversationStream ¶
func (c *Client) AppendConversationStream(ctx context.Context, conversationID string, req *conversation.AppendRequest) (*EventStream, error)
AppendConversationStream appends to a conversation and returns a stream of events.
func (*Client) ArchiveFineTunedModel ¶
func (c *Client) ArchiveFineTunedModel(ctx context.Context, modelID string) (*finetune.ArchiveFTModelOut, error)
ArchiveFineTunedModel archives a fine-tuned model.
func (*Client) ArchiveWorkflow ¶
func (c *Client) ArchiveWorkflow(ctx context.Context, workflowIdentifier string) (*workflow.WorkflowArchiveResponse, error)
ArchiveWorkflow archives a workflow.
func (*Client) BatchCancelWorkflowExecutions ¶
func (c *Client) BatchCancelWorkflowExecutions(ctx context.Context, req *workflow.BatchExecutionBody) (*workflow.BatchExecutionResponse, error)
BatchCancelWorkflowExecutions cancels multiple workflow executions.
func (*Client) BatchTerminateWorkflowExecutions ¶
func (c *Client) BatchTerminateWorkflowExecutions(ctx context.Context, req *workflow.BatchExecutionBody) (*workflow.BatchExecutionResponse, error)
BatchTerminateWorkflowExecutions terminates multiple workflow executions.
func (*Client) BulkDeleteDatasetRecords ¶
func (c *Client) BulkDeleteDatasetRecords(ctx context.Context, req *observability.BulkDeleteRecordsRequest) error
BulkDeleteDatasetRecords deletes multiple dataset records.
func (*Client) CallConnectorTool ¶
func (c *Client) CallConnectorTool(ctx context.Context, idOrName, toolName string, req *connector.CallToolRequest) (*connector.CallToolResponse, error)
CallConnectorTool invokes a tool on a connector.
func (*Client) CancelBatchJob ¶
CancelBatchJob requests cancellation of a batch job.
func (*Client) CancelFineTuningJob ¶
CancelFineTuningJob requests cancellation of a fine-tuning job.
func (*Client) CancelWorkflowExecution ¶
CancelWorkflowExecution cancels a workflow execution.
func (*Client) ChatComplete ¶
func (c *Client) ChatComplete(ctx context.Context, req *chat.CompletionRequest) (*chat.CompletionResponse, error)
ChatComplete sends a chat completion request and returns the full response.
Example ¶
package main
import (
"context"
"fmt"
"log"
mistral "github.com/VikingOwl91/mistral-go-sdk"
"github.com/VikingOwl91/mistral-go-sdk/chat"
)
func main() {
client := mistral.NewClient("sk-your-api-key")
resp, err := client.ChatComplete(context.Background(), &chat.CompletionRequest{
Model: "mistral-small-latest",
Messages: []chat.Message{
&chat.UserMessage{Content: chat.TextContent("What is the capital of France?")},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Choices[0].Message.Content)
}
Output:
func (*Client) ChatCompleteStream ¶
func (c *Client) ChatCompleteStream(ctx context.Context, req *chat.CompletionRequest) (*Stream[chat.CompletionChunk], error)
ChatCompleteStream sends a chat completion request and returns a stream of completion chunks. The caller must call Close() on the returned stream.
Example ¶
package main
import (
"context"
"fmt"
"log"
mistral "github.com/VikingOwl91/mistral-go-sdk"
"github.com/VikingOwl91/mistral-go-sdk/chat"
)
func main() {
client := mistral.NewClient("sk-your-api-key")
stream, err := client.ChatCompleteStream(context.Background(), &chat.CompletionRequest{
Model: "mistral-small-latest",
Messages: []chat.Message{
&chat.UserMessage{Content: chat.TextContent("Tell me a short joke.")},
},
})
if err != nil {
log.Fatal(err)
}
defer stream.Close()
for stream.Next() {
chunk := stream.Current()
if len(chunk.Choices) > 0 {
fmt.Print(chunk.Choices[0].Delta.Content)
}
}
if err := stream.Err(); err != nil {
log.Fatal(err)
}
}
Output:
func (*Client) Classify ¶
func (c *Client) Classify(ctx context.Context, req *classification.Request) (*classification.Response, error)
Classify sends a text classification request.
func (*Client) ClassifyChat ¶
func (c *Client) ClassifyChat(ctx context.Context, req *classification.ChatRequest) (*classification.Response, error)
ClassifyChat sends a chat classification request.
func (*Client) CreateAgent ¶
CreateAgent creates a new agent.
func (*Client) CreateBatchJob ¶
CreateBatchJob creates a new batch inference job.
func (*Client) CreateCampaign ¶
func (c *Client) CreateCampaign(ctx context.Context, req *observability.CreateCampaignRequest) (*observability.Campaign, error)
CreateCampaign creates a new observability campaign.
func (*Client) CreateConnector ¶
func (c *Client) CreateConnector(ctx context.Context, req *connector.CreateRequest) (*connector.Connector, error)
CreateConnector registers a new MCP connector.
func (*Client) CreateDataset ¶
func (c *Client) CreateDataset(ctx context.Context, req *observability.CreateDatasetRequest) (*observability.Dataset, error)
CreateDataset creates a new observability dataset.
func (*Client) CreateDatasetRecord ¶
func (c *Client) CreateDatasetRecord(ctx context.Context, datasetID string, req *observability.CreateRecordRequest) (*observability.DatasetRecord, error)
CreateDatasetRecord creates a record in a dataset.
func (*Client) CreateEmbeddings ¶
func (c *Client) CreateEmbeddings(ctx context.Context, req *embedding.Request) (*embedding.Response, error)
CreateEmbeddings sends an embedding request and returns the response.
Example ¶
package main
import (
"context"
"fmt"
"log"
mistral "github.com/VikingOwl91/mistral-go-sdk"
"github.com/VikingOwl91/mistral-go-sdk/embedding"
)
func main() {
client := mistral.NewClient("sk-your-api-key")
resp, err := client.CreateEmbeddings(context.Background(), &embedding.Request{
Model: "mistral-embed",
Input: []string{"Hello world"},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Embedding dimension: %d\n", len(resp.Data[0].Embedding))
}
Output:
func (*Client) CreateFineTuningJob ¶
func (c *Client) CreateFineTuningJob(ctx context.Context, req *finetune.JobIn) (*finetune.JobOut, error)
CreateFineTuningJob creates a new fine-tuning job.
func (*Client) CreateJudge ¶
func (c *Client) CreateJudge(ctx context.Context, req *observability.CreateJudgeRequest) (*observability.Judge, error)
CreateJudge creates a new observability judge.
func (*Client) CreateLibrary ¶
func (c *Client) CreateLibrary(ctx context.Context, req *library.CreateRequest) (*library.Library, error)
CreateLibrary creates a new document library.
func (*Client) CreateVoice ¶
func (c *Client) CreateVoice(ctx context.Context, req *audio.VoiceCreateRequest) (*audio.VoiceResponse, error)
CreateVoice creates a custom voice.
func (*Client) DeleteAgent ¶
DeleteAgent deletes an agent.
func (*Client) DeleteAgentAlias ¶
DeleteAgentAlias deletes an agent version alias.
func (*Client) DeleteBatchJob ¶
DeleteBatchJob deletes a batch job.
func (*Client) DeleteCampaign ¶
DeleteCampaign deletes a campaign.
func (*Client) DeleteConnector ¶
DeleteConnector deletes a connector.
func (*Client) DeleteConversation ¶
DeleteConversation deletes a conversation.
func (*Client) DeleteDataset ¶
DeleteDataset deletes a dataset.
func (*Client) DeleteDatasetRecord ¶
DeleteDatasetRecord deletes a dataset record.
func (*Client) DeleteDocument ¶
DeleteDocument deletes a document from a library.
func (*Client) DeleteFile ¶
DeleteFile deletes a file by ID.
func (*Client) DeleteJudge ¶
DeleteJudge deletes a judge.
func (*Client) DeleteLibrary ¶
DeleteLibrary deletes a library and all its documents.
func (*Client) DeleteModel ¶
DeleteModel deletes a fine-tuned model by ID.
func (*Client) DeleteVoice ¶
DeleteVoice deletes a voice.
func (*Client) ExecuteWorkflow ¶
func (c *Client) ExecuteWorkflow(ctx context.Context, workflowIdentifier string, req *workflow.ExecutionRequest) (*workflow.ExecutionResponse, error)
ExecuteWorkflow executes a workflow.
func (*Client) ExecuteWorkflowAndWait ¶
func (c *Client) ExecuteWorkflowAndWait(ctx context.Context, workflowIdentifier string, req *workflow.ExecutionRequest) (*workflow.ExecutionResponse, error)
ExecuteWorkflowAndWait executes a workflow and polls until completion.
func (*Client) ExecuteWorkflowRegistration
deprecated
func (c *Client) ExecuteWorkflowRegistration(ctx context.Context, registrationID string, req *workflow.ExecutionRequest) (*workflow.ExecutionResponse, error)
ExecuteWorkflowRegistration executes a workflow via its registration.
Deprecated: Use ExecuteWorkflow instead. This method will be removed in a future release.
func (*Client) ExportDatasetToJSONL ¶
func (c *Client) ExportDatasetToJSONL(ctx context.Context, datasetID string) (*observability.ExportDatasetResponse, error)
ExportDatasetToJSONL exports a dataset to JSONL format.
func (*Client) FIMComplete ¶
func (c *Client) FIMComplete(ctx context.Context, req *fim.CompletionRequest) (*chat.CompletionResponse, error)
FIMComplete sends a Fill-In-the-Middle completion request.
func (*Client) FIMCompleteStream ¶
func (c *Client) FIMCompleteStream(ctx context.Context, req *fim.CompletionRequest) (*Stream[chat.CompletionChunk], error)
FIMCompleteStream sends a FIM request and returns a stream of chunks.
func (*Client) GetAgentVersion ¶
func (c *Client) GetAgentVersion(ctx context.Context, agentID string, version string) (*agents.Agent, error)
GetAgentVersion retrieves a specific version of an agent.
func (*Client) GetBatchJob ¶
GetBatchJob retrieves a batch job by ID.
func (*Client) GetCampaign ¶
func (c *Client) GetCampaign(ctx context.Context, campaignID string) (*observability.Campaign, error)
GetCampaign retrieves a campaign by ID.
func (*Client) GetCampaignStatus ¶
func (c *Client) GetCampaignStatus(ctx context.Context, campaignID string) (*observability.CampaignStatusResponse, error)
GetCampaignStatus retrieves the status of a campaign.
func (*Client) GetChatCompletionEvent ¶
func (c *Client) GetChatCompletionEvent(ctx context.Context, eventID string) (*observability.ChatCompletionEvent, error)
GetChatCompletionEvent retrieves a chat completion event by ID.
func (*Client) GetChatCompletionFieldOptions ¶ added in v1.4.0
func (c *Client) GetChatCompletionFieldOptions(ctx context.Context, fieldName string, operator observability.FieldOperator) (*observability.ChatCompletionFieldOptions, error)
GetChatCompletionFieldOptions returns the distinct values seen for the given field, filtered by the requested operator.
func (*Client) GetChatCompletionFieldOptionsCounts ¶ added in v1.4.0
func (c *Client) GetChatCompletionFieldOptionsCounts(ctx context.Context, fieldName string, req *observability.FieldOptionCountsRequest) (*observability.FieldOptionCounts, error)
GetChatCompletionFieldOptionsCounts returns per-value event counts for the given field, optionally filtered by the supplied filter payload.
func (*Client) GetChatCompletionFields ¶ added in v1.4.0
func (c *Client) GetChatCompletionFields(ctx context.Context) (*observability.ChatCompletionFields, error)
GetChatCompletionFields returns the searchable field definitions and groups for chat-completion observability events.
func (*Client) GetConnector ¶
GetConnector retrieves a connector by ID or name.
func (*Client) GetConnectorAuthURL ¶
func (c *Client) GetConnectorAuthURL(ctx context.Context, idOrName string, appReturnURL *string) (*connector.AuthURLResponse, error)
GetConnectorAuthURL returns the OAuth2 authorization URL for a connector.
func (*Client) GetConversation ¶
func (c *Client) GetConversation(ctx context.Context, conversationID string) (*conversation.Conversation, error)
GetConversation retrieves conversation metadata.
func (*Client) GetConversationHistory ¶
func (c *Client) GetConversationHistory(ctx context.Context, conversationID string) (*conversation.History, error)
GetConversationHistory returns the full history of a conversation.
func (*Client) GetConversationMessages ¶
func (c *Client) GetConversationMessages(ctx context.Context, conversationID string) (*conversation.Messages, error)
GetConversationMessages returns the messages of a conversation.
func (*Client) GetDataset ¶
GetDataset retrieves a dataset by ID.
func (*Client) GetDatasetRecord ¶
func (c *Client) GetDatasetRecord(ctx context.Context, recordID string) (*observability.DatasetRecord, error)
GetDatasetRecord retrieves a dataset record by ID.
func (*Client) GetDatasetTask ¶
func (c *Client) GetDatasetTask(ctx context.Context, datasetID, taskID string) (*observability.DatasetImportTask, error)
GetDatasetTask retrieves an import task by ID.
func (*Client) GetDocument ¶
func (c *Client) GetDocument(ctx context.Context, libraryID, documentID string) (*library.Document, error)
GetDocument retrieves a document's metadata.
func (*Client) GetDocumentExtractedTextSignedURL ¶
func (c *Client) GetDocumentExtractedTextSignedURL(ctx context.Context, libraryID, documentID string) (string, error)
GetDocumentExtractedTextSignedURL retrieves a signed URL for the extracted text.
func (*Client) GetDocumentSignedURL ¶
func (c *Client) GetDocumentSignedURL(ctx context.Context, libraryID, documentID string) (string, error)
GetDocumentSignedURL retrieves a signed URL for downloading a document.
func (*Client) GetDocumentStatus ¶
func (c *Client) GetDocumentStatus(ctx context.Context, libraryID, documentID string) (*library.ProcessingStatusOut, error)
GetDocumentStatus retrieves the processing status of a document.
func (*Client) GetDocumentTextContent ¶
func (c *Client) GetDocumentTextContent(ctx context.Context, libraryID, documentID string) (*library.DocumentTextContent, error)
GetDocumentTextContent retrieves the extracted text of a document.
func (*Client) GetFileContent ¶
GetFileContent downloads the raw content of a file. The caller must close the returned ReadCloser.
func (*Client) GetFileURL ¶
func (c *Client) GetFileURL(ctx context.Context, fileID string, expiryHours int) (*file.SignedURL, error)
GetFileURL returns a signed URL for downloading a file. Expiry is in hours (default 24 if 0).
func (*Client) GetFineTuningJob ¶
GetFineTuningJob retrieves a fine-tuning job by ID.
func (*Client) GetLibrary ¶
GetLibrary retrieves a library by ID.
func (*Client) GetSimilarChatCompletionEvents ¶
func (c *Client) GetSimilarChatCompletionEvents(ctx context.Context, eventID string, params *observability.PaginationParams) (*observability.SimilarEventsResponse, error)
GetSimilarChatCompletionEvents retrieves events similar to a given event.
func (*Client) GetVoiceSampleAudio ¶
GetVoiceSampleAudio retrieves the sample audio for a voice. Returns the raw HTTP response; the caller must close the body.
func (*Client) GetWorkflow ¶
func (c *Client) GetWorkflow(ctx context.Context, workflowIdentifier string) (*workflow.Workflow, error)
GetWorkflow retrieves a workflow by identifier.
func (*Client) GetWorkflowDeployment ¶
func (c *Client) GetWorkflowDeployment(ctx context.Context, deploymentID string) (*workflow.Deployment, error)
GetWorkflowDeployment retrieves a workflow deployment by ID.
func (*Client) GetWorkflowExecution ¶
func (c *Client) GetWorkflowExecution(ctx context.Context, executionID string) (*workflow.ExecutionResponse, error)
GetWorkflowExecution retrieves a workflow execution by ID.
func (*Client) GetWorkflowExecutionHistory ¶
func (c *Client) GetWorkflowExecutionHistory(ctx context.Context, executionID string, decodePayloads *bool) (json.RawMessage, error)
GetWorkflowExecutionHistory retrieves the history of a workflow execution.
func (*Client) GetWorkflowExecutionTraceEvents ¶
func (c *Client) GetWorkflowExecutionTraceEvents(ctx context.Context, executionID string, params *workflow.TraceEventsParams) (*workflow.TraceEventsResponse, error)
GetWorkflowExecutionTraceEvents retrieves the trace events for a workflow execution.
func (*Client) GetWorkflowExecutionTraceOTel ¶
func (c *Client) GetWorkflowExecutionTraceOTel(ctx context.Context, executionID string) (*workflow.TraceOTelResponse, error)
GetWorkflowExecutionTraceOTel retrieves the OpenTelemetry trace for a workflow execution.
func (*Client) GetWorkflowExecutionTraceSummary ¶
func (c *Client) GetWorkflowExecutionTraceSummary(ctx context.Context, executionID string) (*workflow.TraceSummaryResponse, error)
GetWorkflowExecutionTraceSummary retrieves the trace summary for a workflow execution.
func (*Client) GetWorkflowMetrics ¶
func (c *Client) GetWorkflowMetrics(ctx context.Context, workflowName string, params *workflow.MetricsParams) (*workflow.Metrics, error)
GetWorkflowMetrics retrieves performance metrics for a workflow.
func (*Client) GetWorkflowRegistration ¶
func (c *Client) GetWorkflowRegistration(ctx context.Context, registrationID string, params *workflow.RegistrationGetParams) (*workflow.Registration, error)
GetWorkflowRegistration retrieves a workflow registration by ID.
func (*Client) GetWorkflowRun ¶
GetWorkflowRun retrieves a workflow run by ID.
func (*Client) GetWorkflowRunHistory ¶
GetWorkflowRunHistory retrieves the history of a workflow run.
func (*Client) GetWorkflowWorkerInfo ¶
GetWorkflowWorkerInfo returns the scheduler URL, namespace, and TLS setting the API expects custom workers to connect with.
Most callers using managed deployments do not need this — see Registration.DeploymentID. It is exposed for users running custom workers.
func (*Client) ImportDatasetFromCampaign ¶
func (c *Client) ImportDatasetFromCampaign(ctx context.Context, datasetID string, req *observability.ImportFromCampaignRequest) (*observability.DatasetImportTask, error)
ImportDatasetFromCampaign imports records from a campaign.
func (*Client) ImportDatasetFromDataset ¶
func (c *Client) ImportDatasetFromDataset(ctx context.Context, datasetID string, req *observability.ImportFromDatasetRequest) (*observability.DatasetImportTask, error)
ImportDatasetFromDataset imports records from another dataset.
func (*Client) ImportDatasetFromExplorer ¶
func (c *Client) ImportDatasetFromExplorer(ctx context.Context, datasetID string, req *observability.ImportFromExplorerRequest) (*observability.DatasetImportTask, error)
ImportDatasetFromExplorer imports records from explorer events.
func (*Client) ImportDatasetFromFile ¶
func (c *Client) ImportDatasetFromFile(ctx context.Context, datasetID string, req *observability.ImportFromFileRequest) (*observability.DatasetImportTask, error)
ImportDatasetFromFile imports records from a file.
func (*Client) ImportDatasetFromPlayground ¶
func (c *Client) ImportDatasetFromPlayground(ctx context.Context, datasetID string, req *observability.ImportFromPlaygroundRequest) (*observability.DatasetImportTask, error)
ImportDatasetFromPlayground imports records from playground conversations.
func (*Client) JudgeChatCompletionEvent ¶
func (c *Client) JudgeChatCompletionEvent(ctx context.Context, eventID string, req *observability.JudgeEventRequest) (json.RawMessage, error)
JudgeChatCompletionEvent judges a chat completion event.
func (*Client) JudgeConversation ¶
func (c *Client) JudgeConversation(ctx context.Context, judgeID string, req *observability.JudgeConversationRequest) (json.RawMessage, error)
JudgeConversation performs live judging on a conversation.
func (*Client) JudgeDatasetRecord ¶
func (c *Client) JudgeDatasetRecord(ctx context.Context, recordID string, req *observability.JudgeRecordRequest) (json.RawMessage, error)
JudgeDatasetRecord judges a dataset record.
func (*Client) ListAgentAliases ¶
func (c *Client) ListAgentAliases(ctx context.Context, agentID string) ([]agents.AliasResponse, error)
ListAgentAliases lists all version aliases for an agent.
func (*Client) ListAgentVersions ¶
func (c *Client) ListAgentVersions(ctx context.Context, agentID string, params *agents.ListVersionsParams) ([]agents.Agent, error)
ListAgentVersions lists all versions of an agent.
func (*Client) ListAgents ¶
ListAgents lists agents with optional filters and pagination.
func (*Client) ListBatchJobs ¶
func (c *Client) ListBatchJobs(ctx context.Context, params *batch.ListParams) (*batch.JobsOut, error)
ListBatchJobs lists batch jobs with optional filters.
func (*Client) ListCampaignEvents ¶
func (c *Client) ListCampaignEvents(ctx context.Context, campaignID string, params *observability.PaginationParams) (*observability.ListCampaignEventsResponse, error)
ListCampaignEvents lists events selected by a campaign.
func (*Client) ListCampaigns ¶
func (c *Client) ListCampaigns(ctx context.Context, params *observability.SearchParams) (*observability.ListCampaignsResponse, error)
ListCampaigns lists observability campaigns.
func (*Client) ListConnectorTools ¶
func (c *Client) ListConnectorTools(ctx context.Context, idOrName string, params *connector.ListToolsParams) ([]connector.Tool, error)
ListConnectorTools lists tools exposed by a connector.
func (*Client) ListConnectors ¶
func (c *Client) ListConnectors(ctx context.Context, params *connector.ListParams) ([]connector.Connector, error)
ListConnectors returns all connectors.
func (*Client) ListConversations ¶
func (c *Client) ListConversations(ctx context.Context, params *conversation.ListParams) ([]conversation.Conversation, error)
ListConversations lists conversations with optional pagination.
func (*Client) ListDatasetRecords ¶
func (c *Client) ListDatasetRecords(ctx context.Context, datasetID string, params *observability.PaginationParams) (*observability.ListRecordsResponse, error)
ListDatasetRecords lists records in a dataset.
func (*Client) ListDatasetTasks ¶
func (c *Client) ListDatasetTasks(ctx context.Context, datasetID string, params *observability.PaginationParams) (*observability.ListTasksResponse, error)
ListDatasetTasks lists import tasks for a dataset.
func (*Client) ListDatasets ¶
func (c *Client) ListDatasets(ctx context.Context, params *observability.SearchParams) (*observability.ListDatasetsResponse, error)
ListDatasets lists observability datasets.
func (*Client) ListDocuments ¶
func (c *Client) ListDocuments(ctx context.Context, libraryID string, params *library.ListDocumentParams) (*library.ListDocumentOut, error)
ListDocuments lists documents in a library.
func (*Client) ListFiles ¶
func (c *Client) ListFiles(ctx context.Context, params *file.ListParams) (*file.ListResponse, error)
ListFiles returns a list of uploaded files.
func (*Client) ListFineTuningJobs ¶
func (c *Client) ListFineTuningJobs(ctx context.Context, params *finetune.ListParams) (*finetune.JobsOut, error)
ListFineTuningJobs lists fine-tuning jobs with optional filters.
func (*Client) ListJudges ¶
func (c *Client) ListJudges(ctx context.Context, params *observability.SearchParams) (*observability.ListJudgesResponse, error)
ListJudges lists observability judges.
func (*Client) ListLibraries ¶
func (c *Client) ListLibraries(ctx context.Context, params *library.ListLibraryParams) (*library.ListLibraryOut, error)
ListLibraries lists all accessible libraries.
func (*Client) ListLibrarySharing ¶
func (c *Client) ListLibrarySharing(ctx context.Context, libraryID string) (*library.ListSharingOut, error)
ListLibrarySharing lists all sharing entries for a library.
func (*Client) ListModels ¶
func (c *Client) ListModels(ctx context.Context, params *model.ListParams) (*model.ModelList, error)
ListModels returns a list of available models.
func (*Client) ListVoices ¶
ListVoices returns available voices.
func (*Client) ListWorkflowDeployments ¶
func (c *Client) ListWorkflowDeployments(ctx context.Context, params *workflow.DeploymentListParams) (*workflow.DeploymentListResponse, error)
ListWorkflowDeployments lists workflow deployments.
func (*Client) ListWorkflowEvents ¶
func (c *Client) ListWorkflowEvents(ctx context.Context, params *workflow.EventListParams) (*workflow.EventListResponse, error)
ListWorkflowEvents lists workflow events.
func (*Client) ListWorkflowRegistrations ¶
func (c *Client) ListWorkflowRegistrations(ctx context.Context, params *workflow.RegistrationListParams) (*workflow.RegistrationListResponse, error)
ListWorkflowRegistrations lists workflow registrations.
func (*Client) ListWorkflowRuns ¶
func (c *Client) ListWorkflowRuns(ctx context.Context, params *workflow.RunListParams) (*workflow.ListRunsResponse, error)
ListWorkflowRuns lists workflow runs.
func (*Client) ListWorkflowSchedules ¶
ListWorkflowSchedules lists workflow schedules.
func (*Client) ListWorkflows ¶
func (c *Client) ListWorkflows(ctx context.Context, params *workflow.WorkflowListParams) (*workflow.WorkflowListResponse, error)
ListWorkflows lists workflows.
func (*Client) Moderate ¶
func (c *Client) Moderate(ctx context.Context, req *moderation.Request) (*moderation.Response, error)
Moderate sends a text moderation request.
func (*Client) ModerateChat ¶
func (c *Client) ModerateChat(ctx context.Context, req *moderation.ChatRequest) (*moderation.Response, error)
ModerateChat sends a chat moderation request.
func (*Client) QueryWorkflowExecution ¶
func (c *Client) QueryWorkflowExecution(ctx context.Context, executionID string, req *workflow.QueryInvocationBody) (*workflow.QueryResponse, error)
QueryWorkflowExecution queries a workflow execution.
func (*Client) ReprocessDocument ¶
ReprocessDocument triggers reprocessing of a document.
func (*Client) ResetWorkflowExecution ¶
func (c *Client) ResetWorkflowExecution(ctx context.Context, executionID string, req *workflow.ResetInvocationBody) error
ResetWorkflowExecution resets a workflow execution to a specific event.
func (*Client) RestartConversation ¶
func (c *Client) RestartConversation(ctx context.Context, conversationID string, req *conversation.RestartRequest) (*conversation.Response, error)
RestartConversation restarts a conversation from a specific entry.
func (*Client) RestartConversationStream ¶
func (c *Client) RestartConversationStream(ctx context.Context, conversationID string, req *conversation.RestartRequest) (*EventStream, error)
RestartConversationStream restarts a conversation and returns a stream of events.
func (*Client) ScheduleWorkflow ¶
func (c *Client) ScheduleWorkflow(ctx context.Context, req *workflow.ScheduleRequest) (*workflow.ScheduleResponse, error)
ScheduleWorkflow creates a workflow schedule.
func (*Client) SearchChatCompletionEventIDs ¶
func (c *Client) SearchChatCompletionEventIDs(ctx context.Context, req *observability.SearchEventIDsRequest) (*observability.SearchEventIDsResponse, error)
SearchChatCompletionEventIDs searches for chat completion event IDs.
func (*Client) SearchChatCompletionEvents ¶
func (c *Client) SearchChatCompletionEvents(ctx context.Context, req *observability.SearchEventsRequest) (*observability.SearchEventsResponse, error)
SearchChatCompletionEvents searches for chat completion events.
func (*Client) SetAgentAlias ¶
func (c *Client) SetAgentAlias(ctx context.Context, agentID string, alias string, version int) (*agents.AliasResponse, error)
SetAgentAlias creates or updates an agent version alias.
func (*Client) ShareLibrary ¶
func (c *Client) ShareLibrary(ctx context.Context, libraryID string, req *library.SharingRequest) (*library.SharingOut, error)
ShareLibrary creates or updates a sharing entry.
func (*Client) SignalWorkflowExecution ¶
func (c *Client) SignalWorkflowExecution(ctx context.Context, executionID string, req *workflow.SignalInvocationBody) (*workflow.SignalResponse, error)
SignalWorkflowExecution sends a signal to a workflow execution.
func (*Client) Speech ¶
func (c *Client) Speech(ctx context.Context, req *audio.SpeechRequest) (*audio.SpeechResponse, error)
Speech sends a text-to-speech request and returns the full response.
func (*Client) SpeechStream ¶
func (c *Client) SpeechStream(ctx context.Context, req *audio.SpeechRequest) (*SpeechStream, error)
SpeechStream sends a text-to-speech request and returns a stream of audio events.
func (*Client) StartConversation ¶
func (c *Client) StartConversation(ctx context.Context, req *conversation.StartRequest) (*conversation.Response, error)
StartConversation creates and starts a new conversation.
func (*Client) StartConversationStream ¶
func (c *Client) StartConversationStream(ctx context.Context, req *conversation.StartRequest) (*EventStream, error)
StartConversationStream creates a conversation and returns a stream of events.
func (*Client) StartFineTuningJob ¶
StartFineTuningJob starts a validated fine-tuning job.
func (*Client) StreamWorkflowEvents ¶
func (c *Client) StreamWorkflowEvents(ctx context.Context, params *workflow.EventStreamParams) (*WorkflowEventStream, error)
StreamWorkflowEvents streams workflow events via SSE.
func (*Client) StreamWorkflowExecution ¶
func (c *Client) StreamWorkflowExecution(ctx context.Context, executionID string, params *workflow.StreamParams) (*WorkflowEventStream, error)
StreamWorkflowExecution streams events for a workflow execution via SSE.
func (*Client) TerminateWorkflowExecution ¶
TerminateWorkflowExecution terminates a workflow execution.
func (*Client) Transcribe ¶
func (c *Client) Transcribe(ctx context.Context, req *audio.TranscriptionRequest, filename string, file io.Reader) (*audio.TranscriptionResponse, error)
Transcribe sends an audio file for transcription. If file is non-nil, it's uploaded via multipart. Otherwise, FileURL or FileID must be set.
func (*Client) TranscribeStream ¶
func (c *Client) TranscribeStream(ctx context.Context, req *audio.TranscriptionRequest, filename string, file io.Reader) (*AudioStream, error)
TranscribeStream sends an audio file for streaming transcription.
func (*Client) UnarchiveFineTunedModel ¶
func (c *Client) UnarchiveFineTunedModel(ctx context.Context, modelID string) (*finetune.UnarchiveFTModelOut, error)
UnarchiveFineTunedModel unarchives a fine-tuned model.
func (*Client) UnarchiveWorkflow ¶
func (c *Client) UnarchiveWorkflow(ctx context.Context, workflowIdentifier string) (*workflow.WorkflowArchiveResponse, error)
UnarchiveWorkflow unarchives a workflow.
func (*Client) UnscheduleWorkflow ¶
UnscheduleWorkflow removes a workflow schedule.
func (*Client) UnshareLibrary ¶
func (c *Client) UnshareLibrary(ctx context.Context, libraryID string, req *library.SharingDeleteRequest) (*library.SharingOut, error)
UnshareLibrary deletes a sharing entry.
func (*Client) UpdateAgent ¶
func (c *Client) UpdateAgent(ctx context.Context, agentID string, req *agents.UpdateRequest) (*agents.Agent, error)
UpdateAgent updates an agent, creating a new version.
func (*Client) UpdateAgentVersion ¶
func (c *Client) UpdateAgentVersion(ctx context.Context, agentID string, version int) (*agents.Agent, error)
UpdateAgentVersion switches an agent to a specific version.
func (*Client) UpdateConnector ¶
func (c *Client) UpdateConnector(ctx context.Context, idOrName string, req *connector.UpdateRequest) (*connector.Connector, error)
UpdateConnector updates an existing connector.
func (*Client) UpdateDataset ¶
func (c *Client) UpdateDataset(ctx context.Context, datasetID string, req *observability.UpdateDatasetRequest) (*observability.Dataset, error)
UpdateDataset updates a dataset.
func (*Client) UpdateDatasetRecordPayload ¶
func (c *Client) UpdateDatasetRecordPayload(ctx context.Context, recordID string, req *observability.UpdateRecordPayloadRequest) (*observability.DatasetRecord, error)
UpdateDatasetRecordPayload updates a record's payload.
func (*Client) UpdateDatasetRecordProperties ¶
func (c *Client) UpdateDatasetRecordProperties(ctx context.Context, recordID string, req *observability.UpdateRecordPropertiesRequest) (*observability.DatasetRecord, error)
UpdateDatasetRecordProperties updates a record's properties.
func (*Client) UpdateDocument ¶
func (c *Client) UpdateDocument(ctx context.Context, libraryID, documentID string, req *library.DocumentUpdateRequest) (*library.Document, error)
UpdateDocument updates a document's metadata.
func (*Client) UpdateFineTunedModel ¶
func (c *Client) UpdateFineTunedModel(ctx context.Context, modelID string, req *finetune.UpdateFTModelIn) (json.RawMessage, error)
UpdateFineTunedModel updates a fine-tuned model's name or description.
func (*Client) UpdateJudge ¶
func (c *Client) UpdateJudge(ctx context.Context, judgeID string, req *observability.UpdateJudgeRequest) (*observability.Judge, error)
UpdateJudge updates a judge.
func (*Client) UpdateLibrary ¶
func (c *Client) UpdateLibrary(ctx context.Context, libraryID string, req *library.UpdateRequest) (*library.Library, error)
UpdateLibrary updates a library's name and description.
func (*Client) UpdateVoice ¶
func (c *Client) UpdateVoice(ctx context.Context, voiceID string, req *audio.VoiceUpdateRequest) (*audio.VoiceResponse, error)
UpdateVoice updates a voice.
func (*Client) UpdateWorkflow ¶
func (c *Client) UpdateWorkflow(ctx context.Context, workflowIdentifier string, req *workflow.WorkflowUpdateRequest) (*workflow.Workflow, error)
UpdateWorkflow updates a workflow.
func (*Client) UpdateWorkflowExecution ¶
func (c *Client) UpdateWorkflowExecution(ctx context.Context, executionID string, req *workflow.UpdateInvocationBody) (*workflow.UpdateResponse, error)
UpdateWorkflowExecution sends an update to a workflow execution.
type EventStream ¶
type EventStream struct {
// contains filtered or unexported fields
}
EventStream wraps the generic Stream to provide typed conversation events.
func (*EventStream) Close ¶
func (s *EventStream) Close() error
Close releases the underlying connection.
func (*EventStream) Current ¶
func (s *EventStream) Current() conversation.Event
Current returns the most recently read event.
func (*EventStream) Err ¶
func (s *EventStream) Err() error
Err returns any error encountered during streaming.
func (*EventStream) Next ¶
func (s *EventStream) Next() bool
Next advances to the next event. Returns false when done or on error.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient sets the underlying HTTP client.
func WithTimeout ¶
WithTimeout sets the HTTP client timeout.
type SpeechStream ¶
type SpeechStream struct {
// contains filtered or unexported fields
}
SpeechStream wraps the generic Stream for speech streaming events.
func (*SpeechStream) Close ¶
func (s *SpeechStream) Close() error
Close releases the underlying connection.
func (*SpeechStream) Current ¶
func (s *SpeechStream) Current() audio.SpeechStreamEvent
Current returns the most recently read event.
func (*SpeechStream) Err ¶
func (s *SpeechStream) Err() error
Err returns any error encountered during streaming.
func (*SpeechStream) Next ¶
func (s *SpeechStream) Next() bool
Next advances to the next event. Returns false when done or on error.
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
Stream is a generic iterator for streaming API responses. Use Next() to advance, Current() to read the value, Err() for errors, and Close() when done.
func (*Stream[T]) Current ¶
func (s *Stream[T]) Current() T
Current returns the most recently read value. Only valid after Next() returns true.
type WorkflowEventStream ¶
type WorkflowEventStream struct {
// contains filtered or unexported fields
}
WorkflowEventStream wraps the generic Stream to provide typed workflow events with StreamPayload envelope metadata.
func (*WorkflowEventStream) Close ¶
func (s *WorkflowEventStream) Close() error
Close releases the underlying connection.
func (*WorkflowEventStream) Current ¶
func (s *WorkflowEventStream) Current() workflow.Event
Current returns the most recently read workflow event.
func (*WorkflowEventStream) CurrentPayload ¶
func (s *WorkflowEventStream) CurrentPayload() *workflow.StreamPayload
CurrentPayload returns the full StreamPayload envelope of the current event.
func (*WorkflowEventStream) Err ¶
func (s *WorkflowEventStream) Err() error
Err returns any error encountered during streaming.
func (*WorkflowEventStream) Next ¶
func (s *WorkflowEventStream) Next() bool
Next advances to the next event. Returns false when done or on error.
Source Files
¶
- agents_complete.go
- agents_crud.go
- audio_api.go
- batch_api.go
- chat_complete.go
- connectors.go
- conversations.go
- doc.go
- embeddings.go
- error.go
- files.go
- fim_complete.go
- finetune_api.go
- libraries.go
- mistral.go
- models.go
- moderations.go
- observability_campaigns.go
- observability_datasets.go
- observability_events.go
- observability_fields.go
- observability_judges.go
- ocr_api.go
- option.go
- request.go
- sse.go
- stream.go
- workflows.go
- workflows_deployments.go
- workflows_events.go
- workflows_executions.go
- workflows_metrics.go
- workflows_runs.go
- workflows_schedules.go
- workflows_workers.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agents provides types for the Mistral agents API, including agent CRUD operations and agent chat completions.
|
Package agents provides types for the Mistral agents API, including agent CRUD operations and agent chat completions. |
|
Package audio provides types for the Mistral audio APIs.
|
Package audio provides types for the Mistral audio APIs. |
|
Package batch provides types for the Mistral batch jobs API.
|
Package batch provides types for the Mistral batch jobs API. |
|
Package chat provides types for the Mistral chat completion API.
|
Package chat provides types for the Mistral chat completion API. |
|
Package classification provides types for the Mistral classification API.
|
Package classification provides types for the Mistral classification API. |
|
Package connector provides types for the Mistral connectors API.
|
Package connector provides types for the Mistral connectors API. |
|
Package conversation provides types for the Mistral conversations API.
|
Package conversation provides types for the Mistral conversations API. |
|
Package embedding provides types for the Mistral embeddings API.
|
Package embedding provides types for the Mistral embeddings API. |
|
Package file provides types for the Mistral files API, including upload, download, and metadata operations.
|
Package file provides types for the Mistral files API, including upload, download, and metadata operations. |
|
Package fim provides types for the Mistral Fill-in-the-Middle (FIM) completion API, used for code infilling tasks.
|
Package fim provides types for the Mistral Fill-in-the-Middle (FIM) completion API, used for code infilling tasks. |
|
Package finetune provides types for the Mistral fine-tuning API, including job creation, monitoring, and model archiving.
|
Package finetune provides types for the Mistral fine-tuning API, including job creation, monitoring, and model archiving. |
|
Package library provides types for the Mistral document libraries API, including library and document CRUD, sharing, and processing.
|
Package library provides types for the Mistral document libraries API, including library and document CRUD, sharing, and processing. |
|
Package model provides types for Mistral model listing and metadata.
|
Package model provides types for Mistral model listing and metadata. |
|
Package moderation provides types for the Mistral moderation API.
|
Package moderation provides types for the Mistral moderation API. |
|
Package observability provides types for the Mistral observability API (beta).
|
Package observability provides types for the Mistral observability API (beta). |
|
Package ocr provides types for the Mistral OCR API, including document processing with page-level extraction.
|
Package ocr provides types for the Mistral OCR API, including document processing with page-level extraction. |
|
Package workflow provides types for the Mistral workflows API.
|
Package workflow provides types for the Mistral workflows API. |