{
  "description": "OpenAI function calling definitions for TheRouter.ai API. These can be passed directly to the 'tools' parameter of any OpenAI-compatible chat completion request.",
  "base_url": "https://api.therouter.ai",
  "functions": [
    {
      "type": "function",
      "function": {
        "name": "create_chat_completion",
        "description": "Send a chat completion request through TheRouter gateway. Supports 200+ models across OpenAI, Anthropic, Google, Meta, and more. Returns a ChatCompletion object with model response, usage stats, and finish reason.",
        "parameters": {
          "type": "object",
          "properties": {
            "model": {
              "type": "string",
              "description": "Model alias in provider/model format. Examples: 'openai/gpt-4o', 'openai/gpt-4o-mini', 'google/gemini-2.0-flash'. Required unless 'models' array is provided."
            },
            "messages": {
              "type": "array",
              "description": "Conversation history. Each message has 'role' and 'content'.",
              "items": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "enum": ["system", "user", "assistant", "tool"],
                    "description": "Message author role."
                  },
                  "content": {
                    "type": "string",
                    "description": "Message text content."
                  },
                  "tool_call_id": {
                    "type": "string",
                    "description": "Required for role=tool. ID of the tool call this message responds to."
                  }
                },
                "required": ["role"]
              }
            },
            "temperature": {
              "type": "number",
              "description": "Sampling temperature (0–2). Default varies by model."
            },
            "max_tokens": {
              "type": "integer",
              "description": "Maximum tokens to generate in the response."
            },
            "stream": {
              "type": "boolean",
              "description": "If true, returns server-sent events. Default: false."
            },
            "tools": {
              "type": "array",
              "description": "Function definitions the model may call.",
              "items": {
                "type": "object",
                "properties": {
                  "type": { "type": "string", "enum": ["function"] },
                  "function": {
                    "type": "object",
                    "properties": {
                      "name": { "type": "string" },
                      "description": { "type": "string" },
                      "parameters": { "type": "object" }
                    },
                    "required": ["name", "parameters"]
                  }
                }
              }
            },
            "response_format": {
              "type": "object",
              "description": "Set to {\"type\":\"json_object\"} for JSON mode."
            },
            "models": {
              "type": "array",
              "items": { "type": "string" },
              "description": "TheRouter extension: fallback model chain. Tries models in order until success."
            },
            "provider": {
              "type": "object",
              "description": "TheRouter extension: provider routing preferences.",
              "properties": {
                "allow_fallbacks": { "type": "boolean" },
                "order": { "type": "array", "items": { "type": "string" } },
                "only": { "type": "array", "items": { "type": "string" } },
                "ignore": { "type": "array", "items": { "type": "string" } }
              }
            },
            "route": {
              "type": "string",
              "enum": ["fallback", "sort"],
              "description": "TheRouter extension: routing strategy."
            }
          },
          "required": ["messages"]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "list_models",
        "description": "List all available models on TheRouter gateway. Returns model IDs, pricing, context lengths, supported parameters, and architecture metadata. GET /v1/models",
        "parameters": {
          "type": "object",
          "properties": {},
          "required": []
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "get_credits",
        "description": "Check credit balance and total usage. Requires management API key (sk-mgmt-... prefix). GET /api/v1/credits. Returns {data: {total_credits, total_usage}}.",
        "parameters": {
          "type": "object",
          "properties": {},
          "required": []
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "create_embedding",
        "description": "Create vector embeddings for input text. POST /v1/embeddings. Returns embedding vectors for use in search, clustering, and similarity tasks.",
        "parameters": {
          "type": "object",
          "properties": {
            "model": {
              "type": "string",
              "description": "Embedding model ID, e.g. 'openai/text-embedding-3-small'."
            },
            "input": {
              "description": "Text to embed. String or array of strings.",
              "oneOf": [
                { "type": "string" },
                { "type": "array", "items": { "type": "string" } }
              ]
            },
            "encoding_format": {
              "type": "string",
              "enum": ["float", "base64"],
              "description": "Output format. Default: 'float'."
            }
          },
          "required": ["model", "input"]
        }
      }
    }
  ]
}
