Documentation
¶
Overview ¶
Package errorformat decodes the error body formats that more than one provider package receives, such as OpenAI's, which OpenAI-compatible APIs copy. A format that only one package receives stays in that package.
Index ¶
- func DashScopeKind(code string) sdk.ErrorKind
- func DecodeDashScope(e *sdk.APIError)
- func DecodeDeepgram(e *sdk.APIError)
- func DecodeElevenLabs(e *sdk.APIError)
- func DecodeGoogle(e *sdk.APIError)
- func DecodeOpenAI(e *sdk.APIError)
- func DecodeOpenAIErrorEvent(e *sdk.APIError)
- func DecodeOpenAIFailedEvent(e *sdk.APIError)
- func DecodeOpenRouter(e *sdk.APIError)
- func DeepgramKind(code string) sdk.ErrorKind
- func ElevenLabsKind(typ, code string) sdk.ErrorKind
- func GoogleKind(status, reason string) sdk.ErrorKind
- func OpenAIKind(typ, code string) sdk.ErrorKind
- func OpenRouterKind(errorType string) sdk.ErrorKind
- func ParseOpenAI(e *sdk.APIError)
- func ParseOpenAIErrorEvent(e *sdk.APIError)
- func ParseOpenAIFailedEvent(e *sdk.APIError)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DashScopeKind ¶
DashScopeKind classifies a DashScope error code. Arrearage and the free-tier stop arrive as 400 and 403, so the status alone would misfile them.
func DecodeDashScope ¶
DecodeDashScope is the error decoder for Alibaba Cloud Model Studio's DashScope API (https://help.aliyun.com/zh/model-studio/error-code). The request ID comes from the body.
func DecodeDeepgram ¶
DecodeDeepgram fills e from a Deepgram error body, documented at https://developers.deepgram.com/docs/errors. Most endpoints send {"err_code":"...","err_msg":"...","request_id":"..."}; the 503 example spells the code error_code, and JSON validation failures send {"category":"...","message":"...","details":"...","request_id":"..."}. category becomes Type. The dg-request-id response header carries the same ID, see https://developers.deepgram.com/docs/text-to-speech.
func DecodeElevenLabs ¶
DecodeElevenLabs fills e from an ElevenLabs error body, documented at https://elevenlabs.io/docs/eleven-api/resources/errors: {"detail":{"type":"...","code":"...","message":"...","status":"...","request_id":"...","param":"..."}}. Some endpoints still send only the legacy fields, {"detail":{"status":"model_not_found","message":"..."}}, so Code falls back to status. The x-trace-id response header carries the same ID as request_id and is the only ID on a legacy body. A body in any other shape keeps the Kind derived from the status.
func DecodeGoogle ¶
DecodeGoogle is the error decoder for Google APIs, which report errors as a google.rpc.Status. Type is the canonical status (error.status) and Code is the reason of the google.rpc.ErrorInfo detail, when there is one. The APIs document no request ID header, so RequestID stays empty.
RESOURCE_EXHAUSTED covers per-minute and per-day quotas alike. When a google.rpc.QuotaFailure detail names a daily quota among its violations, the Kind is KindQuotaExhausted: the quota resets once a day, whatever delay the RetryInfo detail suggests.
func DecodeOpenAI ¶
DecodeOpenAI is the error decoder for OpenAI's API and the OpenAI-compatible endpoints the OpenAI-format packages are pointed at. The request ID comes from x-request-id, or from x-amzn-requestid on Amazon Bedrock.
func DecodeOpenAIErrorEvent ¶
DecodeOpenAIErrorEvent is DecodeOpenAI for a Responses "error" stream event.
func DecodeOpenAIFailedEvent ¶
DecodeOpenAIFailedEvent is DecodeOpenAI for a Responses "response.failed" stream event.
func DecodeOpenRouter ¶
DecodeOpenRouter is the error decoder for OpenRouter (https://openrouter.ai/docs/api-reference/errors). Code is the numeric code as text and Type is metadata.error_type, which OpenRouter documents as the field to classify by. RequestID is the x-generation-id response header, which OpenRouter sends on chat completion errors and lists in Access-Control-Expose-Headers; its API reference does not describe it.
func DeepgramKind ¶
DeepgramKind classifies a Deepgram err_code. INSUFFICIENT_PERMISSIONS arrives as 401 as well as 403, so the status alone would misfile it.
func ElevenLabsKind ¶
ElevenLabsKind classifies an ElevenLabs error type and code.
func GoogleKind ¶
GoogleKind classifies a google.rpc.Status by its ErrorInfo reason and, when the reason has no mapping, by its canonical status. The reasons are values of google.api.ErrorReason (https://github.com/googleapis/googleapis/blob/master/google/api/error_reason.proto).
func OpenAIKind ¶
OpenAIKind classifies OpenAI's error type and code. It returns KindUnknown for values it has no mapping for, including every value an OpenAI-compatible API invents.
func OpenRouterKind ¶
OpenRouterKind classifies an OpenRouter metadata.error_type.
func ParseOpenAI ¶
ParseOpenAI copies type, code and message from an OpenAI-format body into e. A numeric code is copied as its decimal text.
func ParseOpenAIErrorEvent ¶
ParseOpenAIErrorEvent copies code and message from a Responses "error" stream event into e: from the top level when it carries either, otherwise type, code and message from the nested error object.
func ParseOpenAIFailedEvent ¶
ParseOpenAIFailedEvent copies type, code and message from the error object of a Responses "response.failed" stream event into e.
Types ¶
This section is empty.