> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Error Handling

> Handle API errors in the Go SDK.

# Error Handling

The SDK returns `MeshAPIError` for structural API failures.

```go
resp, err := client.Chat.Completions.Create(ctx, params)
if err != nil {
    var svcErr *meshapi.MeshAPIError
    if errors.As(err, &svcErr) {
        fmt.Printf("Error %d (%s): %s\n", svcErr.Status, svcErr.Code, svcErr.Message)
        fmt.Println("Request ID:", svcErr.RequestID)

        if svcErr.Code == "rate_limit_exceeded" {
            fmt.Printf("Retry after %v seconds\n", svcErr.RetryAfterSeconds)
        }
    } else {
        // Network or context error
        log.Fatal(err)
    }
}
```

## Common Error Codes

| Code                   | Status | Description                          |
| ---------------------- | ------ | ------------------------------------ |
| `unauthorized`         | 401    | Invalid or missing API key           |
| `rate_limit_exceeded`  | 429    | You have hit a rate limit            |
| `spend_limit_exceeded` | 402    | Your spend cap has been reached      |
| `model_not_found`      | 404    | The requested model is not available |
| `upstream_error`       | 500    | An error occurred with the provider  |