Go SDK
Go SDK
A fast, zero-dependency Go client for the MeshAPI AI model gateway.
Requirements
- Go ≥ 1.21
Installation
Quick Start
Basic Chat Completion
Streaming Chat Completion
Streaming is handled elegantly using Go channels. The client returns both a data channel and an error channel to process chunks asynchronously.
Error Handling & Resiliency
Retries occur automatically on 429, 502, 503, and 504 errors using exponential backoff (defaulting to 3 retries, maximum 30 seconds wait, adhering to the Retry-After header).
You can catch structured MeshAPIError wrappers:
[!WARNING] Streams do not automatically retry! On a network connection failure mid-stream, the error channel receives a
MeshAPIErrorwithCode="stream_interrupted". Restarting theStreamcall is required to resume.