Skip to content

Commit 33d2ff9

Browse files
committed
fix: change openai default model to gpt5nano
1 parent 6181edf commit 33d2ff9

23 files changed

Lines changed: 97 additions & 131 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ResilientLLM } from 'resilient-llm';
1616

1717
const llm = new ResilientLLM({
1818
aiService: 'openai',
19-
model: 'gpt-4o-mini',
19+
model: 'gpt-5-nano',
2020
});
2121

2222
const conversationHistory = [

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { ResilientLLM } from 'resilient-llm';
3434

3535
const llm = new ResilientLLM({
3636
aiService: 'openai', // or 'anthropic', 'google', 'ollama'
37-
model: 'gpt-4o-mini',
37+
model: 'gpt-5-nano',
3838
maxTokens: 2048,
3939
temperature: 0.7,
4040
rateLimitConfig: {
@@ -61,6 +61,8 @@ const conversationHistory = [
6161
})();
6262
```
6363

64+
**Handling Error:** typescript users can import `ResilientLLMError` and use the `error.code` to deal with various errors. The canonical list is [`ResilientLLMErrorCode`](./lib/ResilientLLMError.ts) in the source. Javascript users can use the error object properties { name="ResilientLLMError", code, message, metadata, retryable }.
65+
6466
## Key Methods
6567

6668
**Instance methods**

docs/reference.md

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ new ResilientLLM(options?: ResilientLLMOptions)
6666
```javascript
6767
const llm = new ResilientLLM({
6868
aiService: 'openai',
69-
model: 'gpt-4o-mini',
69+
model: 'gpt-5-nano',
7070
maxTokens: 2048,
7171
temperature: 0.7,
7272
rateLimitConfig: {
@@ -155,13 +155,8 @@ Use one naming style per field to avoid ambiguity:
155155

156156
**Throws:**
157157

158-
- `Error` - If input tokens exceed `maxInputTokens`
159-
- `Error` - If API key is not set for the selected service (unless auth is optional)
160-
- `Error` - If the AI service/provider is invalid
161-
- `Error` - If API request fails
162-
- `Error` - If JSON mode parsing fails (`code: "JSON_PARSE_ERROR"`, `rawResponse`)
163-
- `Error` - If JSON response is not an object (`code: "JSON_MODE_FAILURE"`, `rawResponse`)
164-
- `Error` - If schema validation fails (`code: "SCHEMA_MISMATCH"`, `rawResponse`, `validation: SchemaValidationIssue`)
158+
- **`ResilientLLMError`** — Normalized failures from `chat()` (after internal retries when applicable). Use **`error.code`** (`ResilientLLMErrorCode`), **`error.retryable`**, **`error.metadata`**, and **`error.cause`** (log server-side). The canonical code list is in [`lib/ResilientLLMError.ts`](../lib/ResilientLLMError.ts).
159+
- Structured output failures use codes such as **`JSON_PARSE_ERROR`**, **`JSON_MODE_FAILURE`**, **`SCHEMA_MISMATCH`**, or **`VALIDATION_ERROR`**; details may appear on **`error.cause`**.
165160

166161
**Notes:**
167162

@@ -207,15 +202,15 @@ const response = await llm.chat(conversationHistory, {
207202
const response = await llm.chat(conversationHistory, {
208203
apiKey: 'sk-custom-key-here',
209204
aiService: 'openai',
210-
model: 'gpt-4o-mini'
205+
model: 'gpt-5-nano'
211206
});
212207
```
213208

214209
**Example with operation metadata:**
215210
```javascript
216211
const llm = new ResilientLLM({
217212
aiService: 'openai',
218-
model: 'gpt-4o-mini',
213+
model: 'gpt-5-nano',
219214
});
220215

221216
const { content, metadata } = await llm.chat(conversationHistory);
@@ -292,41 +287,26 @@ const { system, messages } = llm.formatMessageForAnthropic(messages);
292287
293288
---
294289
295-
#### `parseError(statusCode, error)`
290+
#### `parseError(statusCode, error, operationMetadata?)`
296291
297-
Parses errors from various LLM APIs to create uniform error messages. This method is called internally when errors occur.
292+
Normalizes an error into **`ResilientLLMError`**. Used internally when `chat()` fails; you can call it directly if you need the same mapping (e.g. tests).
298293
299294
**Signature:**
300295
```typescript
301-
parseError(statusCode: number | null, error: Error | Object | null): never
296+
parseError(statusCode: number | null, error: Error, operationMetadata?: OperationMetadata | null): never
302297
```
303298
304299
**Parameters:**
305300
306301
| Parameter | Type | Required | Description |
307302
|-----------|------|----------|-------------|
308-
| `statusCode` | `number \| null` | Yes | HTTP status code or null for general errors |
309-
| `error` | `Error \| Object \| null` | Yes | Error object |
303+
| `statusCode` | `number \| null` | Yes | Provider HTTP status when known, or `null` |
304+
| `error` | `Error` | Yes | Underlying error |
305+
| `operationMetadata` | `OperationMetadata \| null` | No | Merged onto the thrown error’s `metadata` |
310306
311-
**Returns:** `never` - Always throws an error
307+
**Returns:** `never` — always throws **`ResilientLLMError`**.
312308
313-
**Throws:** `Error` with appropriate message based on status code
314-
315-
**Status Code Mappings:**
316-
317-
| Status Code | Error Message |
318-
|------------|---------------|
319-
| `400` | "Bad request" |
320-
| `401` | "Invalid API Key" |
321-
| `403` | "You are not authorized to access this resource" |
322-
| `404` | "Not found" |
323-
| `429` | "Rate limit exceeded" |
324-
| `500` | "Internal server error" |
325-
| `503` | "Service unavailable" |
326-
| `529` | "API temporarily overloaded" |
327-
| Other | "Unknown error" |
328-
329-
**Note:** This method is called internally by the `chat()` method when errors occur. You typically don't need to call it directly.
309+
If `error` is already a **`ResilientLLMError`**, it is rethrown (metadata may be merged). Otherwise **`statusCode`** selects a **`PROVIDER_*`** code (e.g. `401``PROVIDER_UNAUTHORIZED`); `null` or unknown statuses map to **`PROVIDER_ERROR`**. See [`lib/ResilientLLMError.ts`](../lib/ResilientLLMError.ts) for the full `ResilientLLMErrorCode` union.
330310
331311
---
332312
@@ -684,7 +664,7 @@ responseFormat: {
684664
**End-to-end example (schema mode)**
685665
686666
```typescript
687-
const llm = new ResilientLLM({ aiService: 'openai', model: 'gpt-4o-mini' });
667+
const llm = new ResilientLLM({ aiService: 'openai', model: 'gpt-5-nano' });
688668

689669
const result = await llm.chat(
690670
[{ role: 'user', content: 'Return an answer and citations.' }],
@@ -775,27 +755,11 @@ interface Tool {
775755
776756
## Error Codes
777757
778-
### HTTP Status Codes
779-
780-
| Code | Meaning | Behavior |
781-
|------|---------|----------|
782-
| `200` | Success | Returns parsed response |
783-
| `400` | Bad Request | Throws error |
784-
| `401` | Unauthorized | Throws "Invalid API Key" error |
785-
| `403` | Forbidden | Throws authorization error |
786-
| `404` | Not Found | Throws "Not found" error |
787-
| `429` | Rate Limit Exceeded | Triggers retry with alternate service |
788-
| `500` | Internal Server Error | Retries with backoff |
789-
| `503` | Service Unavailable | Retries with backoff |
790-
| `529` | API Overloaded | Triggers retry with alternate service |
758+
Failures from **`chat()`** are thrown as **`ResilientLLMError`** (see `chat()` **Throws** above). That type is the consumer-facing surface: **`code`**, **`retryable`**, optional **`metadata`** (same shape as success), and **`cause`** for logging.
791759
792-
### Error Types
760+
**Stable string codes** — **`ResilientLLMErrorCode`** in [`lib/ResilientLLMError.ts`](../lib/ResilientLLMError.ts) (including `PROVIDER_*`, structured-output codes, resilience-related codes, and configuration/capability codes). **`retryable`** is defined there for codes where a simple retry might help.
793761
794-
| Error Name | Description | Retry Behavior |
795-
|------------|-------------|----------------|
796-
| `AbortError` | Operation was aborted | No retry |
797-
| `TimeoutError` | Operation timed out | Retries with backoff |
798-
| `Error` (message: "Circuit breaker is open") | Circuit breaker is open | No retry until cooldown expires |
762+
Use **`error.code`** for branching, not raw HTTP status. When a provider HTTP status was available to the library, it may also appear under **`metadata`** (e.g. `provider.httpStatus` / `http`).
799763
800764
---
801765
@@ -917,7 +881,7 @@ Same format as OpenAI response.
917881
Each service has a default model configured. Use `ProviderRegistry.getDefaultModels()` to get all default models:
918882
919883
- **Anthropic:** `claude-3-5-sonnet-20240620`
920-
- **OpenAI:** `gpt-4o-mini`
884+
- **OpenAI:** `gpt-5-nano`
921885
- **Google:** `gemini-2.0-flash`
922886
- **Ollama:** `llama3.1:8b`
923887
@@ -1001,7 +965,7 @@ Timeouts are enforced using `AbortController`:
1001965
1002966
- Timeout applies to entire operation (including retries)
1003967
- On timeout, `AbortController` aborts the HTTP request
1004-
- Throws `TimeoutError` if operation exceeds timeout
968+
- **`chat()`** rejects with **`ResilientLLMError`**; the original timeout is typically on **`error.cause`** (`name` may be `TimeoutError`)
1005969
1006970
---
1007971

docs/resilience-configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ await llm.chat(conversationHistory, {
458458
```javascript
459459
const llm = new ResilientLLM({
460460
aiService: 'openai',
461-
model: 'gpt-4o-mini',
461+
model: 'gpt-5-nano',
462462

463463
// Resilience configuration
464464
retries: 5, // More retries for production
@@ -510,7 +510,7 @@ const llm = new ResilientLLM({
510510
```javascript
511511
const llm = new ResilientLLM({
512512
aiService: 'openai',
513-
model: 'gpt-4o-mini',
513+
model: 'gpt-5-nano',
514514

515515
// Aggressive retry strategy
516516
retries: 3,

examples/chat-basic/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Set your API key and choose the default LLM service and model:
4949
# OpenAI
5050
export OPENAI_API_KEY=your_key_here
5151
export AI_SERVICE=openai
52-
export AI_MODEL=gpt-4o-mini
52+
export AI_MODEL=gpt-5-nano
5353

5454
# Or Anthropic
5555
export ANTHROPIC_API_KEY=your_key_here
@@ -94,7 +94,7 @@ import { ResilientLLM } from 'resilient-llm';
9494

9595
const llm = new ResilientLLM({
9696
aiService: process.env.AI_SERVICE || 'openai',
97-
model: process.env.AI_MODEL || 'gpt-4o-mini',
97+
model: process.env.AI_MODEL || 'gpt-5-nano',
9898
maxTokens: 2048,
9999
temperature: 0.7,
100100
rateLimitConfig: {

examples/chat-basic/server/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ app.use(express.static(join(__dirname, '../client')));
1919
// Initialize ResilientLLM
2020
const llm = new ResilientLLM({
2121
aiService: process.env.AI_SERVICE || 'openai',
22-
model: process.env.AI_MODEL || 'gpt-4o-mini',
22+
model: process.env.AI_MODEL || 'gpt-5-nano',
2323
maxTokens: parseInt(process.env.MAX_TOKENS || '2048'),
2424
temperature: parseFloat(process.env.TEMPERATURE || '0.7'),
2525
rateLimitConfig: {

examples/playground-js/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Set your API key and choose the default LLM service and model:
6969
# OpenAI
7070
export OPENAI_API_KEY=your_key_here
7171
export AI_SERVICE=openai
72-
export AI_MODEL=gpt-4o-mini
72+
export AI_MODEL=gpt-5-nano
7373

7474
# Or Anthropic
7575
export ANTHROPIC_API_KEY=your_key_here

examples/playground-js/client/core/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ export class App {
707707
_setFallbackDefaults() {
708708
this.settings.setConfig({
709709
service: 'openai',
710-
model: 'gpt-4o-mini',
710+
model: 'gpt-5-nano',
711711
temperature: '0.7',
712712
maxTokens: '2048'
713713
});

examples/playground-js/server/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ app.use(express.static(join(__dirname, '../client')));
1919
// Initialize ResilientLLM
2020
const llm = new ResilientLLM({
2121
aiService: process.env.AI_SERVICE || 'openai',
22-
model: process.env.AI_MODEL || 'gpt-4o-mini',
22+
model: process.env.AI_MODEL || 'gpt-5-nano',
2323
maxTokens: parseInt(process.env.MAX_TOKENS || '2048'),
2424
temperature: parseFloat(process.env.TEMPERATURE || '0.7'),
2525
rateLimitConfig: {

examples/playground-nextjs/src/app/api/chat/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ export async function POST(request: NextRequest) {
6565

6666
// Get the appropriate model for the service
6767
const defaultModels: Record<string, string> = {
68-
openai: 'gpt-4o-mini',
68+
openai: 'gpt-5-nano',
6969
anthropic: 'claude-3-5-sonnet-20240620',
7070
gemini: 'gemini-2.0-flash',
7171
ollama: 'llama3.1:8b'
7272
};
7373

74-
const selectedModel = model || defaultModels[aiService] || 'gpt-4o-mini';
74+
const selectedModel = model || defaultModels[aiService] || 'gpt-5-nano';
7575

7676
resilienceLog.push({
7777
type: 'info',
@@ -202,7 +202,7 @@ export async function GET() {
202202
status: 'ok',
203203
availableServices: ['openai', 'anthropic', 'gemini', 'ollama'],
204204
defaultModels: {
205-
openai: 'gpt-4o-mini',
205+
openai: 'gpt-5-nano',
206206
anthropic: 'claude-3-5-sonnet-20240620',
207207
gemini: 'gemini-2.0-flash',
208208
ollama: 'llama3.1:8b'

0 commit comments

Comments
 (0)