Guides›Best Practices

Best Practices

Follow these recommendations to get the most out of routing.run.

Error handling

  • Handle 429 responses with exponential backoff.
  • Set max_tokens to avoid runaway generation costs.
  • Always check the finish_reason field to know if the response was truncated.

Cost optimization

  • Pick the smallest model that meets your quality bar.
  • Use shorter prompts where possible to reduce token usage.
  • Monitor usage on the dashboard to track spending.

Security

  • Rotate API keys you have not used recently.
  • Use separate keys for each environment.
  • Never commit API keys to version control.