micro/go-micro · error
no response from API
Error message
no response from API
What it means
The Together API returned HTTP 200 with valid JSON but an empty choices array, so there is no message to extract. The library treats this as an error because a chat completion should always contain at least one choice.
Source
Thrown at ai/together/together.go:203
Choices []struct {
Message struct {
Content string `json:"content"`
ToolCalls []struct {
ID string `json:"id"`
Function struct {
Name string `json:"name"`
Arguments string `json:"arguments"`
} `json:"function"`
} `json:"tool_calls"`
} `json:"message"`
} `json:"choices"`
}
if err := json.Unmarshal(respBody, &chatResp); err != nil {
return nil, nil, fmt.Errorf("failed to parse response: %w", err)
}
if len(chatResp.Choices) == 0 {
return nil, nil, fmt.Errorf("no response from API")
}
choice := chatResp.Choices[0]
response := &ai.Response{Reply: choice.Message.Content}
for _, tc := range choice.Message.ToolCalls {
var input map[string]any
if err := json.Unmarshal([]byte(tc.Function.Arguments), &input); err != nil {
input = map[string]any{}
}
response.ToolCalls = append(response.ToolCalls, ai.ToolCall{
ID: tc.ID,
Name: tc.Function.Name,
Input: input,
})
}
rawMessage := map[string]any{View on GitHub (pinned to 24529f1404)
Solutions
- Log the raw respBody to confirm choices is empty vs malformed
- Verify the model name in the request is valid for the endpoint
- Retry the request — empty completions are often transient
- If using a gateway/proxy, test the same request directly against api.together.xyz
Defensive patterns
Strategy: retry
Try / catch
resp, err := p.Generate(ctx, req)
if err != nil {
if strings.Contains(err.Error(), "no response from API") {
// inspect raw body/logs, then retry once
}
} Prevention
- Validate model names before calls
- Retry transient empty completions
- Alert on repeated empty responses (gateway misbehavior)
- Test against api.together.xyz directly when using gateways
When it happens
Trigger: A 200 response whose body is {"choices":[]} — e.g. the model produced no output, an unusual finish configuration, or a gateway echoing an empty success.
Common situations: Content-filtered or empty completions, misconfigured model names on compatible gateways, buggy self-hosted proxies returning empty successful responses.
Understand the failure class
Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.
Related errors
- API request failed: %w
- failed to parse response: %w
- no response from API
- video completed but no outputs returned
- no response from API
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/a4a2090064c51b71.
Report an issue: GitHub.