### OpenAI SDK Streaming Request with BrainstormRouter Source: https://docs.brainstormrouter.com/concepts/streaming-security Demonstrates how to use the OpenAI Python SDK to send a streaming request to the BrainstormRouter API. This example shows the client-side setup and how to iterate through the streamed response chunks. ```python from openai import OpenAI client = OpenAI( base_url="https://api.brainstormrouter.com/v1", api_key="br_live_...", ) stream = client.chat.completions.create( model="anthropic/claude-sonnet-4", messages=[{"role": "user", "content": "Summarize the customer file for Acme Corp."}], stream=True, ) for chunk in stream: print(chunk.choices[0].delta.content, end="") ``` -------------------------------- ### Get Specific Observability Integration Template Source: https://docs.brainstormrouter.com/api-reference/observability Fetches the configuration schema, recommended event types, and an example configuration for a specific observability integration template, such as 'langfuse'. ```curl curl https://api.brainstormrouter.com/v1/observability/templates/langfuse \ -H "Authorization: Bearer br_live_..." ``` -------------------------------- ### List Models API Example (cURL) Source: https://brainstormrouter.com/llms-full.txt This example shows how to list available models using cURL. It requires setting the Authorization header with a Bearer token to authenticate the request to the /v1/models endpoint. ```bash curl https://api.brainstormrouter.com/v1/models \ -H "Authorization: Bearer brk_your_key" ``` -------------------------------- ### Use BrainstormRouter Model Variants with Vercel AI SDK (JavaScript) Source: https://docs.brainstormrouter.com/guides/vercel-ai Illustrates how to use different routing variants of BrainstormRouter models directly with the Vercel AI SDK. Examples include 'floor', 'fast', and 'best' variants. ```javascript const cheap = brainstorm("openai/gpt-4o-mini:floor"); const fast = brainstorm("anthropic/claude-haiku-4-5:fast"); const best = brainstorm("anthropic/claude-sonnet-4:best"); ``` -------------------------------- ### List Available Models - Response Example Source: https://docs.brainstormrouter.com/api-reference/models Example JSON response from the `/v1/models` endpoint. It includes a list of models, each with an ID, object type, creation timestamp, and the owning provider. ```json { "object": "list", "data": [ { "id": "anthropic/claude-sonnet-4", "object": "model", "created": 1700000000, "owned_by": "anthropic" }, { "id": "openai/gpt-4o", "object": "model", "created": 1700000000, "owned_by": "openai" } ] } ``` -------------------------------- ### Error Reference Source: https://docs.brainstormrouter.com/start/quickstart Provides details on status codes and error bodies for the API. ```APIDOC ## GET /api-reference/errors ### Description Retrieves a reference of all possible API errors, including status codes and their corresponding error response bodies. ### Method GET ### Endpoint /api-reference/errors ### Parameters #### Query Parameters None ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **statusCode** (integer) - The HTTP status code associated with the error. - **errorBody** (object) - A description of the error response body structure. #### Response Example ```json { "example": [ { "statusCode": 400, "errorBody": { "code": "INVALID_INPUT", "message": "The provided input is invalid." } }, { "statusCode": 404, "errorBody": { "code": "RESOURCE_NOT_FOUND", "message": "The requested resource could not be found." } } ] } ``` ``` -------------------------------- ### Chat Completion API Example (cURL) Source: https://brainstormrouter.com/llms-full.txt This example demonstrates how to perform a chat completion request using cURL. It includes setting the Authorization header with a Bearer token, specifying the content type, and providing a JSON payload with the model, messages, and stream options. ```bash curl -X POST https://api.brainstormrouter.com/v1/chat/completions \ -H "Authorization: Bearer brk_your_key" \ -H "Content-Type: application/json" \ -d '{ "model": "auto", "messages": [{"role": "user", "content": "Hello"}], "stream": true }' ``` -------------------------------- ### Observability Templates and Testing Source: https://brainstormrouter.com/llms-full.txt This API route provides access to observability templates and allows for testing observability configurations. API Key authentication is required. Use GET /v1/observability/templates to retrieve templates and GET /v1/observability/templates/:provider to get templates for a specific provider. POST /v1/observability/test/:id tests a specific configuration. ```http GET /v1/observability/templates ``` ```http GET /v1/observability/templates/:provider ``` ```http POST /v1/observability/test/:id ``` -------------------------------- ### Agentic Chat Completion with Memory - Python Example Source: https://docs.brainstormrouter.com/concepts/memory Demonstrates how to interact with an agentic chat completion API, showing how the agent can be 'taught' information and later recall it. This highlights the tenant-wide memory scoping where conversation history is not explicitly passed. ```python client.chat.completions.create( model="anthropic/claude-sonnet-4-5", messages=[{"role": "user", "content": "Our deploy target is us-east-1 on ECS Fargate." }], extra_body={"mode": "agentic"}, ) client.chat.completions.create( model="anthropic/claude-sonnet-4-5", messages=[{"role": "user", "content": "Where do we deploy?" }], extra_body={"mode": "agentic"}, ) # → "You deploy to us-east-1 on ECS Fargate." ``` -------------------------------- ### CrewAI Setup and Configuration with BrainstormRouter Source: https://docs.brainstormrouter.com/guides/crewai Install necessary libraries and configure environment variables to point CrewAI's underlying OpenAI SDK to the BrainstormRouter API endpoint. This allows CrewAI to leverage BrainstormRouter's routing capabilities. ```python pip install crewai openai brainstormrouter import os os.environ["OPENAI_API_BASE"] = "https://api.brainstormrouter.com/v1" os.environ["OPENAI_API_KEY"] = "br_live_..." ``` -------------------------------- ### Model Leaderboard - Response Example Source: https://docs.brainstormrouter.com/api-reference/models Example JSON response from the `/v1/models/leaderboard` endpoint. It provides detailed performance metrics for models, including reward scores, quality, latency, pricing, and capabilities, sorted by a specified dimension. ```json { "object": "list", "sort_by": "overall", "model_count": 42, "cached_at": "2026-02-26T12:00:00.000Z", "data": [ { "id": "anthropic/claude-sonnet-4", "provider": "anthropic", "model_id": "claude-sonnet-4", "reward_score": 0.8523, "reward_variance": 0.0012, "validity": 0.9501, "quality": 0.91, "latency_ms": 520.3, "tokens_per_second": 85.2, "success_rate": 0.998, "pricing": { "input": 3, "output": 15 }, "capabilities": ["streaming", "tools", "vision"], "sample_count": 12430, "days_active": 7, "error_rate": 0.002, "value_score": 284.1 } ] } ``` -------------------------------- ### Create a Reusable Preset in JavaScript Source: https://docs.brainstormrouter.com/concepts/routing Illustrates how to create a reusable preset configuration in JavaScript, defining a default model, strategy, fallbacks, and cost limits. Presets simplify complex routing setups. ```javascript await client.presets.create({ slug: "production", name: "Production Config", model: "anthropic/claude-sonnet-4", strategy: "quality", fallbacks: ["openai/gpt-4o", "google/gemini-2.0-flash"], max_cost_usd: 0.50, }); ``` -------------------------------- ### LangChain Streaming Responses with BrainstormRouter Source: https://docs.brainstormrouter.com/guides/langchain Demonstrates how to stream responses from a LangChain model configured with BrainstormRouter. This allows for real-time display of LLM output as it's generated. Requires '@langchain/openai'. ```typescript const stream = await model.stream("Write a haiku about APIs"); for await (const chunk of stream) { process.stdout.write(chunk.content as string); } ``` -------------------------------- ### Perform RAG with LlamaIndex and BrainstormRouter Source: https://docs.brainstormrouter.com/guides/llamaindex Demonstrates how to set up a Retrieval Augmented Generation (RAG) pipeline using LlamaIndex with BrainstormRouter as the LLM. It involves loading documents, creating an index, and querying the index. ```python from llama_index.core import VectorStoreIndex, SimpleDirectoryReader # Load documents documents = SimpleDirectoryReader("./docs").load_data() index = VectorStoreIndex.from_documents(documents, llm=llm) # Query query_engine = index.as_query_engine() response = query_engine.query("What is the main architecture pattern?") print(response) ``` -------------------------------- ### LangChain Basic Usage with BrainstormRouter Source: https://docs.brainstormrouter.com/guides/langchain Demonstrates how to configure LangChain's ChatOpenAI integration to use BrainstormRouter as its LLM backend by setting a custom baseURL. Requires the '@langchain/openai' and 'brainstormrouter' npm packages. ```typescript import { ChatOpenAI } from "@langchain/openai"; const model = new ChatOpenAI({ configuration: { baseURL: "https://api.brainstormrouter.com/v1", }, apiKey: "br_live_...", model: "anthropic/claude-sonnet-4", }); const response = await model.invoke("Explain quantum computing"); console.log(response.content); ``` -------------------------------- ### Fetch Model Leaderboard using cURL Source: https://docs.brainstormrouter.com/api-reference/models This example demonstrates how to retrieve the model leaderboard using a cURL command. It specifies the sorting dimension ('overall') and a limit for the number of results, requiring an API key for authentication. ```bash curl "https://api.brainstormrouter.com/v1/models/leaderboard?sort=overall&limit=10" \ -H "Authorization: Bearer br_live_..." ``` -------------------------------- ### Configure Fallback Chain in JSON Source: https://docs.brainstormrouter.com/concepts/routing Provides an example of configuring fallback models for a chat completion request in JSON format. This ensures that if the primary model fails, the router attempts alternative models in a specified order. ```json { "model": "anthropic/claude-sonnet-4", "route": { "fallbacks": ["openai/gpt-4o", "google/gemini-2.0-flash"], "strategy": "priority" } } ``` -------------------------------- ### Integrate BrainstormRouter Memory with Vercel AI SDK (JavaScript) Source: https://docs.brainstormrouter.com/guides/vercel-ai Demonstrates pre-loading BrainstormRouter memory and using it with the Vercel AI SDK for agentic mode. Memory is initialized once and then used implicitly by the model. ```javascript import BrainstormRouter from "brainstormrouter"; import { streamText } from "ai"; import { createOpenAI } from "@ai-sdk/openai"; const brainstorm = createOpenAI({ baseURL: "https://api.brainstormrouter.com/v1", apiKey: process.env.BRAINSTORMROUTER_API_KEY!, }); // Bootstrap memory once const br = new BrainstormRouter(); await br.memory.init([{ content: "Company: Acme Corp. Product: Widget Pro.", source: "about.md" }]); // Vercel AI SDK uses the enriched model const result = streamText({ model: brainstorm("anthropic/claude-sonnet-4"), messages: [{ role: "user", content: "What product does the company sell?" }], // Pass mode via headers or body extension }); ``` -------------------------------- ### LangChain Tool Calling with BrainstormRouter Source: https://docs.brainstormrouter.com/guides/langchain Illustrates how to enable tool calling functionality in LangChain when using BrainstormRouter. This involves defining tools with descriptions and schemas, then binding them to the LangChain model. Requires '@langchain/openai', '@langchain/core', and 'zod'. ```typescript import { ChatOpenAI } from "@langchain/openai"; import { tool } from "@langchain/core/tools"; import { z } from "zod"; const weatherTool = tool(async ({ city }) => `72°F and sunny in ${city}`, { name: "get_weather", description: "Get weather for a city", schema: z.object({ city: z.string() }), }); const model = new ChatOpenAI({ configuration: { baseURL: "https://api.brainstormrouter.com/v1" }, apiKey: "br_live_...", model: "anthropic/claude-sonnet-4", }).bindTools([weatherTool]); const response = await model.invoke("What's the weather in San Francisco?"); ``` -------------------------------- ### Generate Text with BrainstormRouter and Vercel AI SDK (JavaScript) Source: https://docs.brainstormrouter.com/guides/vercel-ai Demonstrates how to generate text using the BrainstormRouter model via the Vercel AI SDK. It takes a model identifier and a prompt, returning the generated text. ```javascript import { generateText } from "ai"; const { text } = await generateText({ model: brainstorm("anthropic/claude-sonnet-4"), prompt: "Explain quantum computing in one paragraph.", }); ``` -------------------------------- ### Configure BrainstormRouter Provider with Vercel AI SDK (JavaScript) Source: https://docs.brainstormrouter.com/guides/vercel-ai Sets up the BrainstormRouter provider for use with the Vercel AI SDK. It requires the `ai` and `@ai-sdk/openai` packages and configures the base URL and API key for BrainstormRouter. ```javascript import { createOpenAI } from "@ai-sdk/openai"; const brainstorm = createOpenAI({ baseURL: "https://api.brainstormrouter.com/v1", apiKey: "br_live_...", }); ``` -------------------------------- ### Enable Streaming Responses in LlamaIndex with BrainstormRouter Source: https://docs.brainstormrouter.com/guides/llamaindex Shows how to enable streaming responses from LlamaIndex queries when using BrainstormRouter. This allows for real-time token generation, improving user experience for interactive applications. ```python from llama_index.core import Settings Settings.llm = llm query_engine = index.as_query_engine(streaming=True) response = query_engine.query("Summarize the key findings") for token in response.response_gen: print(token, end="", flush=True) ``` -------------------------------- ### Send First Chat Completion Request (Python) Source: https://docs.brainstormrouter.com/start/quickstart This Python snippet demonstrates how to send a chat completion request to BrainstormRouter using the OpenAI SDK. It requires the `openai` library and an API key. The output is the content of the model's response. ```python from openai import OpenAI client = OpenAI( base_url="https://api.brainstormrouter.com/v1", api_key="br_live_...", ) response = client.chat.completions.create( model="anthropic/claude-sonnet-4-5", messages=[{"role": "user", "content": "Explain quantum computing in one paragraph."}] ) print(response.choices[0].message.content) ``` -------------------------------- ### Send First Chat Completion Request (OpenAI SDK - JavaScript) Source: https://docs.brainstormrouter.com/start/quickstart This JavaScript snippet uses the standard OpenAI SDK to interact with BrainstormRouter. It requires the `openai` library and an API key, with the `baseURL` set to the BrainstormRouter endpoint. The output is the content of the model's response. ```javascript import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.brainstormrouter.com/v1", apiKey: "br_live_...", }); const response = await client.chat.completions.create({ model: "openai/gpt-4o", messages: [{ role: "user", content: "Explain quantum computing in one paragraph." }], }); console.log(response.choices[0].message.content); ``` -------------------------------- ### Store RAG Insights in BrainstormRouter Memory Source: https://docs.brainstormrouter.com/guides/llamaindex This example illustrates how to store insights discovered during a RAG process into BrainstormRouter's persistent memory. It uses the `requests` library to make a POST request to the memory entries endpoint. ```python import requests # Store RAG-discovered insights in persistent memory requests.post( "https://api.brainstormrouter.com/v1/memory/entries", headers={"Authorization": "Bearer br_live_..."}, json={ "fact": "Architecture uses event-driven microservices with Kafka", "block": "project", }, ) ``` -------------------------------- ### Send First Chat Completion Request (cURL) Source: https://docs.brainstormrouter.com/start/quickstart This cURL command demonstrates how to send a chat completion request to BrainstormRouter from the command line. It requires an API key and specifies the model and messages in JSON format. The response contains the model's output. ```bash curl https://api.brainstormrouter.com/v1/chat/completions \ -H "Authorization: Bearer br_live_..." \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-4-5", "messages": [{"role": "user", "content": "Explain quantum computing in one paragraph."}] }' ``` -------------------------------- ### Configure LlamaIndex with BrainstormRouter LLM Source: https://docs.brainstormrouter.com/guides/llamaindex This snippet shows how to configure LlamaIndex to use BrainstormRouter as an OpenAI-compatible LLM provider. It requires installing the `llama-index-llms-openai-like` package and setting the API base URL, API key, and desired model. ```python from llama_index.llms.openai_like import OpenAILike llm = OpenAILike( api_base="https://api.brainstormrouter.com/v1", api_key="br_live_...", model="anthropic/claude-sonnet-4", is_chat_model=True, ) ``` -------------------------------- ### Use Auto Routing for Chat Completion (cURL) Source: https://docs.brainstormrouter.com/start/quickstart This cURL command demonstrates how to use auto routing for chat completions by setting the `model` parameter to `"auto"`. BrainstormRouter will then select the best model based on request complexity, cost budget, and learned quality scores. ```bash curl https://api.brainstormrouter.com/v1/chat/completions \ -H "Authorization: Bearer br_live_..." \ -H "Content-Type: application/json" \ -d '{ "model": "auto", "messages": [{"role": "user", "content": "What is 2+2?"}] }' ``` -------------------------------- ### Send First Chat Completion Request (JavaScript) Source: https://docs.brainstormrouter.com/start/quickstart This JavaScript snippet shows how to send a chat completion request to BrainstormRouter using a custom BrainstormRouter SDK. It requires the `brainstormrouter` library and an API key. It also demonstrates appending memory to the conversation. ```javascript import BrainstormRouter from "brainstormrouter"; const client = new BrainstormRouter({ apiKey: "br_live_..." }); const response = await client.chat.completions.create({ model: "openai/gpt-4o", messages: [{ role: "user", content: "Explain quantum computing in one paragraph." }], }); console.log(response.choices[0].message.content); // Plus: memory, guardrails, governance, and more await client.memory.append("User asked about quantum computing", { block: "general" }); ``` -------------------------------- ### Retrieve Memory Blocks Source: https://brainstormrouter.com/llms-full.txt This API route allows retrieval of memory blocks. API Key authentication is required. Use a GET request to /v1/memory/blocks to get all blocks, or /v1/memory/blocks/:block to get a specific block. ```http GET /v1/memory/blocks ``` ```http GET /v1/memory/blocks/:block ``` -------------------------------- ### Get Health Status Source: https://brainstormrouter.com/llms-full.txt This API route retrieves the health status of the BrainstormRouter service. It does not require any authentication. The GET request should be made to the /health endpoint. ```http GET /health ``` -------------------------------- ### Get OpenAPI Specification Source: https://brainstormrouter.com/llms-full.txt This API route provides the OpenAPI specification for the BrainstormRouter API. No authentication is required. Send a GET request to the /openapi.json endpoint to retrieve the specification. ```http GET /openapi.json ``` -------------------------------- ### Configure Batched Webhook Destination (JavaScript) Source: https://docs.brainstormrouter.com/concepts/observability Illustrates setting up a webhook destination with batching enabled to reduce HTTP overhead. This configuration specifies the maximum number of events per batch and the flush interval in milliseconds. ```javascript await client.observability.addDestination({ name: "Analytics", type: "webhook", config: { url: "https://analytics.example.com/ingest" }, batch: { max_size: 100, // flush after 100 events flush_interval_ms: 5000, // or every 5 seconds }, }); ``` -------------------------------- ### LangChain Multi-Model Comparison with BrainstormRouter Presets Source: https://docs.brainstormrouter.com/guides/langchain Shows how to use BrainstormRouter's preset feature within LangChain to perform A/B testing or compare different LLM models easily. This is achieved by specifying preset model names in the LangChain configuration. Requires '@langchain/openai'. ```typescript const cheap = new ChatOpenAI({ configuration: { baseURL: "https://api.brainstormrouter.com/v1" }, apiKey: "br_live_...", model: "@preset/fast-cheap", }); const quality = new ChatOpenAI({ configuration: { baseURL: "https://api.brainstormrouter.com/v1" }, apiKey: "br_live_...", model: "@preset/high-quality", }); ``` -------------------------------- ### Simulate Routing Strategies via cURL Source: https://docs.brainstormrouter.com/concepts/routing Shows how to use the Replays API with cURL to simulate different routing strategies over a specified time period. This is useful for analyzing historical performance and cost. ```shell curl https://api.brainstormrouter.com/v1/replays/simulate \ -H "Authorization: Bearer br_live_..." \ -d '{"strategy": "price", "since": "2025-02-20T00:00:00Z"}' ``` -------------------------------- ### Get Model Leaderboard Source: https://brainstormrouter.com/llms-full.txt This API route provides access to the model leaderboard, ranking models based on performance metrics. API Key authentication is required. Send a GET request to the /v1/models/leaderboard endpoint. ```http GET /v1/models/leaderboard ``` -------------------------------- ### Thread Conversations with Conversation ID (Python) Source: https://docs.brainstormrouter.com/start/quickstart This Python snippet demonstrates how to maintain context across multiple chat completion requests by using a `conversation_id`. The first request sets the context (e.g., remembering a name), and subsequent requests in the same conversation can refer to it. ```python response = client.chat.completions.create( model="auto", messages=[{"role": "user", "content": "Remember that my name is Alice." }], extra_body={"conversation_id": "session-123"}, ) # Later, same conversation: response = client.chat.completions.create( model="auto", messages=[{"role": "user", "content": "What's my name?" }], extra_body={"conversation_id": "session-123"}, ) ``` -------------------------------- ### Manage Guardrail Configurations Source: https://brainstormrouter.com/llms-full.txt This API route allows for the management of guardrail configurations, including retrieving, updating, and managing providers. API Key authentication is required. Endpoints include GET /v1/guardrails/config, PUT /v1/guardrails/config, GET /v1/guardrails/providers, POST /v1/guardrails/providers, and DELETE /v1/guardrails/providers/:id. ```http GET /v1/guardrails/config ``` ```http PUT /v1/guardrails/config ``` ```http GET /v1/guardrails/providers ``` ```http POST /v1/guardrails/providers ``` ```http DELETE /v1/guardrails/providers/:id ``` -------------------------------- ### Initialize and Use BrainstormRouter SDK Source: https://brainstormrouter.com/llms-full.txt Instantiate the BrainstormRouter client with an API key and use it to create chat completions. Supports multiple programming languages. ```bash npm install brainstormrouter ``` ```typescript import { BrainstormRouter } from "brainstormrouter"; const br = new BrainstormRouter({ apiKey: "brk_..." }); const result = await br.chat.completions.create({ model: "auto", messages: [{ role: "user", content: "Hello" }], }); ``` ```bash pip install brainstormrouter ``` ```python from brainstormrouter import BrainstormRouter br = BrainstormRouter(api_key="brk_...") result = br.chat.completions.create( model="auto", messages=[{"role": "user", "content": "Hello"}], ) ``` -------------------------------- ### Manage Presets Source: https://brainstormrouter.com/llms-full.txt This API route allows for the management of presets, including creation, retrieval, updates, and deletion. API Key authentication is required. Endpoints include POST /v1/presets, GET /v1/presets, GET /v1/presets/:slug, PUT /v1/presets/:slug, and DELETE /v1/presets/:slug. ```http POST /v1/presets ``` ```http GET /v1/presets ``` ```http GET /v1/presets/:slug ``` ```http PUT /v1/presets/:slug ``` ```http DELETE /v1/presets/:slug ``` -------------------------------- ### GET /v1/providers/catalog Source: https://brainstormrouter.com/llms-full.txt Retrieves the provider catalog. This endpoint provides access to the provider catalog. ```APIDOC ## GET /v1/providers/catalog ### Description Retrieves the provider catalog. ### Method GET ### Endpoint /v1/providers/catalog ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **catalog** (object) - The provider catalog data. #### Response Example { "catalog": { "providers": [{"name": "OpenAI", "type": "llm"}] } } ``` -------------------------------- ### GET /v1/governance/summary Source: https://brainstormrouter.com/llms-full.txt Retrieves a governance summary. This endpoint provides a summary of governance-related information. ```APIDOC ## GET /v1/governance/summary ### Description Retrieves a governance summary. ### Method GET ### Endpoint /v1/governance/summary ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **summary** (object) - Governance summary data. #### Response Example { "summary": { "status": "ok", "details": "System is running smoothly" } } ``` -------------------------------- ### Reference a Preset in Chat Completion in JavaScript Source: https://docs.brainstormrouter.com/concepts/routing Demonstrates how to reference a previously created preset using its slug in a chat completion request. This applies the saved routing configuration to the request. ```javascript await client.chat.completions.create({ model: "@preset/production", messages: [...], }); ``` -------------------------------- ### GET /v1/governance/behavioral-profiles Source: https://brainstormrouter.com/llms-full.txt Retrieves behavioral profiles. This endpoint allows fetching behavioral profiles. ```APIDOC ## GET /v1/governance/behavioral-profiles ### Description Retrieves behavioral profiles. ### Method GET ### Endpoint /v1/governance/behavioral-profiles ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **profiles** (array) - An array of behavioral profile objects. #### Response Example { "profiles": [ { "role": "user", "profile": {"behavior": "example"} } ] } ``` -------------------------------- ### GET /v1/governance/anomaly/scores Source: https://brainstormrouter.com/llms-full.txt Retrieves anomaly scores. This endpoint provides access to the scores of anomalies. ```APIDOC ## GET /v1/governance/anomaly/scores ### Description Retrieves anomaly scores. ### Method GET ### Endpoint /v1/governance/anomaly/scores ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **scores** (array) - An array of anomaly score objects. #### Response Example { "scores": [ { "metric": "metric1", "score": 0.75 } ] } ``` -------------------------------- ### CrewAI Cost Optimization with BrainstormRouter Presets Source: https://docs.brainstormrouter.com/guides/crewai Utilize BrainstormRouter's preset system to automatically select models based on cost and quality strategies. This example shows assigning a 'high-quality' preset to a research agent and a 'fast-cheap' preset to a formatter agent. ```python # Expensive tasks get the quality model researcher = Agent( role="Research Analyst", llm="@preset/high-quality", # anthropic/claude-sonnet-4, quality strategy ) # Simple tasks get the cheap model formatter = Agent( role="Formatter", llm="@preset/fast-cheap", # openai/gpt-4o-mini, price strategy ) ``` -------------------------------- ### GET /v1/governance/anomaly/history Source: https://brainstormrouter.com/llms-full.txt Retrieves anomaly history. This endpoint provides access to the history of anomalies. ```APIDOC ## GET /v1/governance/anomaly/history ### Description Retrieves the history of anomalies. ### Method GET ### Endpoint /v1/governance/anomaly/history ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **history** (array) - An array of anomaly history objects. #### Response Example { "history": [ { "timestamp": "2024-01-01T00:00:00Z", "description": "Anomaly Description" } ] } ``` -------------------------------- ### GET /v1/mcp/tools Source: https://brainstormrouter.com/llms-full.txt Retrieves available tools for MCP. This endpoint provides a list of available tools. ```APIDOC ## GET /v1/mcp/tools ### Description Retrieves available tools for MCP. ### Method GET ### Endpoint /v1/mcp/tools ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **tools** (array) - An array of available tool objects. #### Response Example { "tools": [ { "toolId": "tool1", "name": "Example Tool" } ] } ``` -------------------------------- ### List Observability Integration Templates Source: https://docs.brainstormrouter.com/api-reference/observability Retrieves a list of available integration templates for various observability platforms. These templates simplify configuration by providing pre-filled schemas and recommended settings. ```curl curl https://api.brainstormrouter.com/v1/observability/templates \ -H "Authorization: Bearer br_live_..." ``` -------------------------------- ### GET /v1/mcp/connect Source: https://brainstormrouter.com/llms-full.txt Retrieves the MCP connection status. This endpoint provides the current connection status. ```APIDOC ## GET /v1/mcp/connect ### Description Retrieves the MCP connection status. ### Method GET ### Endpoint /v1/mcp/connect ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **connection_status** (string) - The connection status. #### Response Example { "connection_status": "connected" } ``` -------------------------------- ### Enable Agentic Mode for Chat Completion Source: https://docs.brainstormrouter.com/start/quickstart This Python snippet shows how to enable agentic mode for a chat completion request by adding `"mode": "agentic"` to the `extra_body`. Agentic mode utilizes BrainstormRouter's autonomous agent engine with built-in memory and tool use. ```python response = client.chat.completions.create( model="anthropic/claude-sonnet-4-5", messages=[{"role": "user", "content": "Summarize yesterday's findings and suggest next steps." }], extra_body={"mode": "agentic"}, ) ``` -------------------------------- ### GET /v1/providers Source: https://brainstormrouter.com/llms-full.txt Retrieves a list of providers. This endpoint allows fetching a list of available providers. ```APIDOC ## GET /v1/providers ### Description Retrieves a list of providers. ### Method GET ### Endpoint /v1/providers ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **providers** (array) - An array of provider objects. #### Response Example { "providers": [ { "providerId": "provider123", "name": "OpenAI", "type": "llm" } ] } ``` -------------------------------- ### GET /v1/governance/memory/stats Source: https://brainstormrouter.com/llms-full.txt Retrieves memory statistics. This endpoint provides access to memory usage statistics. ```APIDOC ## GET /v1/governance/memory/stats ### Description Retrieves memory statistics. ### Method GET ### Endpoint /v1/governance/memory/stats ### Parameters ### Request Example { "example": "" } ### Response #### Success Response (200) - **memory_stats** (object) - Memory usage statistics. #### Response Example { "memory_stats": { "used": 1024, "available": 4096 } } ``` -------------------------------- ### Bootstrap Memory from Documents using cURL Source: https://docs.brainstormrouter.com/api-reference/memory This cURL command shows how to bootstrap agent memory by extracting facts from provided documents. It utilizes an LLM to analyze content and assign facts to appropriate memory blocks. Requires authentication, JSON content type, and a list of documents with their content and source, along with a specified model. ```shell curl -X POST https://api.brainstormrouter.com/v1/memory/init \ -H "Authorization: Bearer br_live_..." \ -H "Content-Type: application/json" \ -d '{ \ "documents": [ \ {"content": "Project uses Next.js 15 with App Router...", "source": "README.md"}, \ {"content": "Deploy to AWS ECS Fargate via GitHub Actions...", "source": "infra.md"} \ ], \ "model": "anthropic/claude-sonnet-4" \ }' ``` -------------------------------- ### GET /v1/governance/agent-manifests Source: https://brainstormrouter.com/llms-full.txt Retrieves agent manifests. This endpoint allows you to fetch the details of agent manifests. ```APIDOC ## GET /v1/governance/agent-manifests ### Description Retrieves a list of agent manifests. ### Method GET ### Endpoint /v1/governance/agent-manifests ### Parameters #### Path Parameters - **agentId** (string) - Required - The ID of the agent. ### Request Example { "example": "" } ### Response #### Success Response (200) - **manifests** (array) - An array of agent manifest objects. #### Response Example { "manifests": [ { "agentId": "agent123", "name": "Agent Name", "description": "Agent Description" } ] } ```