API Documentation

Welcome to the Frosty AI API Reference!

Welcome to the Frosty AI API Reference! Below you'll find everything you need to know to interact with Frosty AI, including authorization, endpoints, request/response formats, and error handling.


πŸ”‘ Authorization

To interact with the Frosty AI API, you need:

  • Router ID β€” Unique ID for your Frosty router.

  • Router Key β€” Secret key for authenticating requests.

You can find both inside the Router Details page in the Frosty AI console.

πŸ” Example of Authorization (Query Params)

https://api.gofrosty.ai/chat?router_id={ROUTER_ID}&router_key={ROUTER_KEY}&prompt=Hello&rule=cost

πŸš€ Endpoints

1. /chat (GET)

URL

https://api.gofrosty.ai/chat

Method

GET

Query Parameters

Parameter

Type

Description

Required

router_id

string

Your Frosty AI Router ID

βœ…

router_key

string

Your Frosty AI Router Key

βœ…

prompt

string

The AI prompt you want Frosty to handle

βœ…

rule

string

Route based on specific logic: cost , performance , or none

βœ…


✨ Routing with rule

Frosty AI lets you manually specify a routing rule to direct traffic to:

  • cost: The most affordable configured model

  • performance: The fastest/most optimized configured model

  • none: Use your primary model or fallback if configured

Note: Ensure you have your cost or performance models configured in the Frosty AI console for this to work.


βœ… Sample Request

GET /chat?router_id=your_router_id&router_key=your_router_key&prompt=Tell me a joke&rule=cost

βœ… cURL Example

curl "https://api.gofrosty.ai/chat?router_id=your_router_id&router_key=your_router_key&prompt=Tell me a joke&rule=cost"

πŸ“€ Response Example (Success)

{
  "trace_id": "abc-1234-5678-xyz",
  "total_tokens": 56,
  "prompt_type": "chat",
  "prompt_tokens": 20,
  "response_tokens": 36,
  "model": "claude-3-sonnet",
  "provider": "Anthropic",
  "total_time": 1423,
  "prompt": "Tell me a joke",
  "cost": "0.01",
  "rule": "cost",
  "response": "Why don’t skeletons fight each other? They don’t have the guts.",
  "success": "True"
}

πŸ“€ Response Example (Failure)

{
  "trace_id": "abc-1234-5678-xyz",
  "total_tokens": 0,
  "prompt_type": "chat",
  "prompt_tokens": 0,
  "response_tokens": 0,
  "model": "None",
  "provider": "None",
  "total_time": 0,
  "prompt": "Tell me a joke",
  "cost": "- -",
  "rule": "cost",
  "response": "No fallback provider configured",
  "success": "False"
}

❗️ Error Codes & Handling

Status Code

Description

Example Error Message

401

Unauthorized: Invalid router_id or router_key

"Unauthorized. Invalid router_id or router_key."

403

Trial expired / Access denied

"Your Frosty AI trial has ended. Subscribe now."

429

Rate limit exceeded

"Rate limit exceeded. Please try again."

502

No fallback provider configured / Upstream failure

"No fallback provider configured."

500

Unknown internal error

"Unexpected error occurred."


πŸ’‘ Example Use Cases

  • Smart AI Routing: Automatically choose the best AI model based on cost and performance.

  • Failover: Switch to backup AI models if the primary model fails or is too slow.

  • Multi-model optimization: Select models based on the type of task or user-defined rules.

  • Cost control: Prioritize cheaper models when possible to reduce costs.

  • Performance tuning: Route to fastest models for time-sensitive tasks.

  • Compliance routing: Route sensitive data to specific compliant models/providers.


βœ… Status Fields Explained

Field

Description

trace_id

Unique request identifier

total_tokens

Total tokens used (input + output)

prompt_type

Type of operation (e.g., "chat")

prompt_tokens

Number of tokens in user prompt

response_tokens

Number of tokens in AI-generated response

model

AI model used for response

provider

AI provider (e.g., OpenAI, Anthropic, Mistral)

total_time

Time in milliseconds taken for full response

prompt

The user prompt submitted

cost

Estimated cost (if calculated)

rule

Routing rule applied (e.g., "cost", "perf")

response

AI-generated response

success

True if operation succeeded, False otherwise


πŸ“¬ Contact & Support

For help or questions, reach out to us:


Updated on