Skip to content

Commit 4043bfd

Browse files
committed
feat(ai): added troubleshooting for generative apis
1 parent 940d3e3 commit 4043bfd

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
meta:
3+
title: Fixing common issues with Generative APIs
4+
description: This page lists common issues that you may encounter while using Scaleway's Generative APIs, their causes and recommended solutions.
5+
content:
6+
h1: Fixing common issues with Generative APIs
7+
paragraph: Generative APIs offer serverless AI models hosted at Scaleway - no need to configure hardware or deploy your own models
8+
tags: generative-apis ai-data common-issues
9+
dates:
10+
validation: 2025-01-16
11+
posted: 2025-01-16
12+
13+
14+
Below are common issues that you may encounter when using Generative APIs, their causes, and recommended solutions.
15+
16+
## 504: Timeout
17+
18+
### Cause
19+
- The query is too long.
20+
- The model goes into an infinite loop while processing the input.
21+
22+
### Solution
23+
- Set a stricter **maximum token limit** to prevent overly long responses.
24+
- Reduce the size of the input tokens, or split the input into multiple API requests.
25+
- Use [Managed Inference](/ai-data/managed-inference/), where no query timeout is enforced.
26+
27+
## Structured output (e.g., JSON) is not working correctly
28+
29+
### Cause
30+
- Incorrect field naming in the request, such as using `"format"` instead of the correct `"response_format"` field.
31+
- Lack of a JSON schema, which can lead to ambiguity in the output structure.
32+
33+
### Solution
34+
- Ensure the proper field `"response_format"` is used in the query.
35+
- Provide a JSON schema in the request to guide the model's structured output.
36+
- Refer to the [documentation on structured outputs](/ai-data/generative-apis/how-to/use-structured-outputs/) for examples and additional guidance.
37+
38+
39+
## Multiple "role": "user" successive messages
40+
41+
### Cause
42+
- Successive messages with `"role": "user"` are sent in the API request instead of alternating between `"role": "user"` and `"role": "assistant"`.
43+
44+
### Solution
45+
- Ensure the `"messages"` array alternates between `"role": "user"` and `"role": "assistant"`.
46+
- If multiple `"role": "user"` messages need to be sent, concatenate them into one `"role": "user"` message or intersperse them with appropriate `"role": "assistant"` responses.
47+
48+
#### Example error message (for Mistral models)
49+
```json
50+
{
51+
"object": "error",
52+
"message": "After the optional system message, conversation roles must alternate user/assistant/user/assistant/...",
53+
"type": "BadRequestError",
54+
"param": null,
55+
"code": 400
56+
}
57+
```
58+
59+
## Best practices for optimizing model performance
60+
61+
### Input size management
62+
- Avoid overly long input sequences; break them into smaller chunks if needed.
63+
- Use summarization techniques for large inputs to reduce token count while maintaining relevance.
64+
65+
### Use proper parameter configuration
66+
- Double-check parameters like `"temperature"`, `"max_tokens"`, and `"top_p"` to ensure they align with your use case.
67+
- For structured output, always include a `"response_format"` and, if possible, a detailed JSON schema.
68+
69+
### Debugging silent errors
70+
- For cases where no explicit error is returned:
71+
- Verify all fields in the API request are correctly named and formatted.
72+
- Test the request with smaller and simpler inputs to isolate potential issues.
73+
74+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
meta:
3+
title: Generative APIs - Troubleshooting
4+
description: Generative APIs - Troubleshooting
5+
content:
6+
h1: Generative APIs - Troubleshooting
7+
paragraph: Generative APIs - Troubleshooting
8+
---

menu/navigation.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,16 @@
838838
],
839839
"label": "Additional Content",
840840
"slug": "reference-content"
841+
},
842+
{
843+
"items": [
844+
{
845+
"label": "Fixing common issues",
846+
"slug": "fixing-common-issues"
847+
}
848+
],
849+
"label": "Troubleshooting",
850+
"slug": "troubleshooting"
841851
}
842852
],
843853
"label": "Generative APIs",

0 commit comments

Comments
 (0)