You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: document fallbackModel option in TypeScript and Python SDK references
Adds a "Model Fallback" section under Client Configuration explaining the
feature with code examples, and adds the fallbackModel/fallback_model field
to the guard, redact, and scan options tables in both SDK pages.
Copy file name to clipboardExpand all lines: docs/content/docs/sdk/sdk/python.mdx
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,30 @@ client = create_client(
70
70
71
71
The fallback URL can also be set via the `SUPERAGENT_FALLBACK_URL` environment variable.
72
72
73
+
### Model Fallback
74
+
75
+
When using third-party providers (e.g., Google Gemini), transient errors like 503 (high demand) or 429 (rate limited) can cause requests to fail. The SDK supports automatic model fallback: if the primary model returns a retryable error, the request is re-issued to a backup model you specify.
76
+
77
+
```python
78
+
result =await client.guard(
79
+
input="user message to analyze",
80
+
model="google/gemini-2.5-flash-lite",
81
+
fallback_model="google/gemini-2.5-pro"
82
+
)
83
+
```
84
+
85
+
If the primary model succeeds, `fallback_model` is never called. If it returns a retryable status code (429, 500, 502, or 503), the SDK automatically retries with the fallback model. The fallback model can be from a different provider entirely:
86
+
87
+
```python
88
+
result =await client.guard(
89
+
input="user message to analyze",
90
+
model="google/gemini-2.5-flash-lite",
91
+
fallback_model="openai/gpt-4o-mini"
92
+
)
93
+
```
94
+
95
+
The `fallback_model` option is available on `guard()`, `redact()`, and `scan()`. The fallback model gets a single attempt — there is no recursive fallback chain.
96
+
73
97
---
74
98
75
99
## Guard
@@ -92,6 +116,7 @@ if result.classification == "block":
Copy file name to clipboardExpand all lines: docs/content/docs/sdk/sdk/typescript.mdx
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,30 @@ const client = createClient({
70
70
71
71
The fallback URL can also be set via the `SUPERAGENT_FALLBACK_URL` environment variable.
72
72
73
+
### Model Fallback
74
+
75
+
When using third-party providers (e.g., Google Gemini), transient errors like 503 (high demand) or 429 (rate limited) can cause requests to fail. The SDK supports automatic model fallback: if the primary model returns a retryable error, the request is re-issued to a backup model you specify.
76
+
77
+
```typescript
78
+
const result =awaitclient.guard({
79
+
input: "user message to analyze",
80
+
model: "google/gemini-2.5-flash-lite",
81
+
fallbackModel: "google/gemini-2.5-pro"
82
+
});
83
+
```
84
+
85
+
If the primary model succeeds, `fallbackModel` is never called. If it returns a retryable status code (429, 500, 502, or 503), the SDK automatically retries with the fallback model. The fallback model can be from a different provider entirely:
86
+
87
+
```typescript
88
+
const result =awaitclient.guard({
89
+
input: "user message to analyze",
90
+
model: "google/gemini-2.5-flash-lite",
91
+
fallbackModel: "openai/gpt-4o-mini"
92
+
});
93
+
```
94
+
95
+
The `fallbackModel` option is available on `guard()`, `redact()`, and `scan()`. The fallback model gets a single attempt — there is no recursive fallback chain.
96
+
73
97
---
74
98
75
99
## Guard
@@ -95,6 +119,7 @@ if (result.classification === "block") {
0 commit comments