Skip to content

Fix reasoning-models.ts example: Update model names and add error handling#79

Merged
saschabuehrle merged 3 commits intomainfrom
fix/reasoning-models-api-access
Nov 20, 2025
Merged

Fix reasoning-models.ts example: Update model names and add error handling#79
saschabuehrle merged 3 commits intomainfrom
fix/reasoning-models-api-access

Conversation

@saschabuehrle
Copy link
Copy Markdown
Collaborator

Summary

Fixes the reasoning-models.ts example to use correct OpenAI reasoning model names and handle API access errors gracefully.

Changes

  • ✅ Updated model names from aspirational (o4-mini, o3) to actual models (o1-mini, o1-preview)
  • ✅ Added try-catch blocks for graceful error handling
  • ✅ Added clear documentation about OpenAI API tier requirements
  • ✅ Updated cost estimates to match current OpenAI pricing
  • ✅ Fixed variable scope issue in Example 4
  • ✅ Added error handling to Claude example

Before

Error: cascadeflow error: openai provider error: OpenAI API error: 403 Forbidden

After

=== Example 1: o1-mini (fast reasoning model) ===
Note: Requires OpenAI Tier 3+ API access
Check your tier at: https://platform.openai.com/settings/organization/limits

Skipping - API access required: ...
Solution: Upgrade to Tier 3+ or use different models

Test Results

  • ✅ Example runs successfully with exit code 0
  • ✅ Graceful degradation when reasoning models unavailable
  • ✅ Example 3 (cascade with fallback) works perfectly
  • ✅ Clear user guidance for API tier requirements

Why This Matters

  • Users were confused by 403 errors from non-existent model names
  • Example now provides helpful guidance instead of crashing
  • Demonstrates best practices for handling API access limitations

Closes issue with reasoning-models.ts failing tests

…r handling

Changes:
- Updated model names to actual OpenAI reasoning models (o1-mini, o1-preview)
- Added try-catch blocks for graceful error handling when API access unavailable
- Added clear notes about OpenAI API tier requirements (Tier 3+ for o1-mini, Tier 5 for o1-preview)
- Updated cost estimates to match current OpenAI pricing
- Fixed Example 4 scope issue by converting to skip message
- Added try-catch to Claude example for resilient execution

Why:
- Example previously used non-existent model names (o4-mini, o3)
- 403/404 errors confused users - now provides helpful guidance
- Makes example runnable even without reasoning model access

Fixes: reasoning-models.ts now runs successfully with exit code 0

Co-authored-by: Sascha Buehrle <sascha.buehrle@gmail.com>
Updated LangChain package documentation and examples to use correct API:
- COST_TRACKING.md: Replaced all `new CascadeFlow({` with `withCascade({`
- cost-tracking-providers.ts: Updated import and usage to use function API

Changes:
- Import: `import { CascadeFlow }` → `import { withCascade }`
- Usage: `new CascadeFlow({...})` → `withCascade({...})`
- Model names: Kept gpt-5-nano and gpt-5 as forward-looking examples

Testing: ✅ Verified with gpt-5 models (exit code 0)
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 20, 2025
Updated MODEL_PRICING_REFERENCE with correct OpenAI GPT-5 pricing:

GPT-5.1:
- Input: $2.00 → $1.25 per 1M tokens
- Output: $15.00 → $10.00 per 1M tokens
- Same pricing as GPT-5

GPT-5 series pricing (confirmed):
- GPT-5.1: $1.25 input, $10.00 output
- GPT-5: $1.25 input, $10.00 output
- GPT-5-mini: $0.25 input, $2.00 output
- GPT-5-nano: $0.05 input, $0.40 output

All prices are non-batch API rates per 1M tokens.
Updated comment from "estimated" to "official non-batch pricing".
@saschabuehrle saschabuehrle merged commit 804cb3c into main Nov 20, 2025
19 checks passed
@saschabuehrle saschabuehrle deleted the fix/reasoning-models-api-access branch November 20, 2025 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation examples lang: typescript size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant