For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DocsAPI ReferenceSDKs
DocsAPI ReferenceSDKs
      • Overview
      • Chat Completions
      • Prompt Templates
      • Files & Batches
      • Embeddings
      • Image Generation
      • Responses (Reasoning)
      • Compare (Multi-model)
      • Models
      • Error Handling
LogoLogo
On this page
  • Error Handling
  • Common Error Codes
Go SDK

Error Handling

||View as Markdown|
Was this page helpful?
Edit this page
Previous

Models

Built with

Error Handling

The SDK returns MeshAPIError for structural API failures.

1resp, err := client.Chat.Completions.Create(ctx, params)
2if err != nil {
3 var svcErr *meshapi.MeshAPIError
4 if errors.As(err, &svcErr) {
5 fmt.Printf("Error %d (%s): %s\n", svcErr.Status, svcErr.Code, svcErr.Message)
6 fmt.Println("Request ID:", svcErr.RequestID)
7
8 if svcErr.Code == "rate_limit_exceeded" {
9 fmt.Printf("Retry after %v seconds\n", svcErr.RetryAfterSeconds)
10 }
11 } else {
12 // Network or context error
13 log.Fatal(err)
14 }
15}

Common Error Codes

CodeStatusDescription
unauthorized401Invalid or missing API key
rate_limit_exceeded429You have hit a rate limit
spend_limit_exceeded402Your spend cap has been reached
model_not_found404The requested model is not available
upstream_error500An error occurred with the provider