### Development Setup Commands Source: https://github.com/tetra-2023/litellm-mcp/blob/main/README.md Commands for setting up the development environment, installing dependencies, and running tests. ```bash uv sync --all-extras --dev uv run pre-commit install uv run pytest -v uv run ruff check src/ tests/ ``` -------------------------------- ### NewProjectRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for creating a new project. ```json { "name": "Project Phoenix", "organization_id": "org-456" } ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/tetra-2023/litellm-mcp/blob/main/README.md Clone the litellm-mcp repository and install its dependencies using uv. ```bash git clone https://github.com/TETRA-2023/litellm-mcp.git cd litellm-mcp uv sync ``` -------------------------------- ### NewUserRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for creating a new internal user. ```json { "username": "newuser", "email": "newuser@example.com", "role": "editor" } ``` -------------------------------- ### NewCustomerRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for creating a new customer account. ```json { "name": "New Customer Inc.", "email": "contact@newcustomer.com", "plan_id": "basic" } ``` -------------------------------- ### NewOrganizationRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for creating a new organization. ```json { "name": "New Org LLC", "owner_email": "owner@neworg.com" } ``` -------------------------------- ### MCPServer Request Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON for creating a new MCP Gateway Server. ```json { "name": "gateway-1", "url": "http://gateway.example.com", "description": "Primary gateway instance." } ``` -------------------------------- ### Project Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'Project' resource, showing its name and associated organization. ```json { "id": "proj-abc", "name": "Alpha Project", "organization_id": "org-123", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### MCPTool Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an MCP Tool resource. ```json { "id": "list_models", "name": "List Models", "description": "Lists all available models.", "parameters": {}, "returns": {"type": "array", "items": {"type": "object"}} } ``` -------------------------------- ### Run the LiteLLM Server Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/README.md Command to start the LiteLLM server using uv and Python. ```bash uv run python src/server.py ``` -------------------------------- ### Budget Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'Budget' resource, including name, amount, and currency. ```json { "id": "budget-q3", "name": "Q3 Marketing Budget", "amount": 5000.0, "currency": "USD", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### NewMCPServerRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for registering a new MCP Gateway Server. ```json { "name": "MCP-Server-01", "url": "http://mcp.example.com/api", "description": "Main MCP server instance." } ``` -------------------------------- ### User Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'User' resource, including username and email. ```json { "id": "user-123", "username": "testuser", "email": "test@example.com", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### Customer Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'Customer' resource, showing name and contact information. ```json { "id": "cust-xyz", "name": "Acme Corp", "email": "contact@acme.com", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z", "status": "active" } ``` -------------------------------- ### Model Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'Model' resource, showing its fields. ```json { "id": "gpt-3.5-turbo", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z", "input_cost": 0.0000015, "output_cost": 0.000002, "description": "OpenAI's fast and affordable model." } ``` -------------------------------- ### Budget Object Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Example of a budget object with standard fields. Used for tracking spending limits and reset periods. ```json { "budget_id": "budget-1", "max_budget": 10000.0, "soft_budget": 8000.0, "budget_duration": "monthly", "tpm_limit": 1000000, "rpm_limit": 5000, "model_max_budget": { "gpt-4o": 5000.0, "claude-3": 3000.0 }, "budget_reset_at": "2025-07-01T00:00:00Z" } ``` -------------------------------- ### Tool Invocation Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Demonstrates a basic pattern for invoking an MCP tool. ```python tool_result = await client.mcp_gateway.invoke_tool( tool_name="list_models", tool_params={} ) print(tool_result) ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/tetra-2023/litellm-mcp/blob/main/README.md Copy the example environment file and edit it with your LiteLLM proxy URL and API key. ```bash cp .env.example .env # Edit .env with your LiteLLM proxy URL and API key ``` -------------------------------- ### GenerateKeyRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for generating a new API key. ```json { "name": "my-new-key", "scopes": ["read", "write"], "expires_in_days": 30 } ``` -------------------------------- ### Credential Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'Credential' resource, including its type and name. ```json { "id": "cred-123", "name": "openai-api-key", "type": "api_key", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### Key Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an API 'Key' resource, showing its ID, name, and status. ```json { "id": "key-abc", "name": "app-key-1", "scopes": ["read", "write"], "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z", "status": "active" } ``` -------------------------------- ### SpendRecord Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of a 'SpendRecord' resource, detailing usage and cost. ```json { "id": "spend-xyz", "resource_type": "chat_completion", "model_id": "gpt-3.5-turbo", "cost": 0.0005, "timestamp": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### Organization Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an 'Organization' resource, including its name and owner. ```json { "id": "org-123", "name": "Tech Solutions Inc.", "owner_email": "admin@techsolutions.com", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### ChatCompletion Response Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON response for a chat completion request. ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1678886400, "model": "gpt-3.5-turbo", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello there! How can I help you today?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` -------------------------------- ### AccessGroup Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an 'AccessGroup' resource, detailing its properties. ```json { "id": "research-models", "name": "Research Models", "description": "Models available for research purposes.", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### MCPSubmission Request Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON for submitting a tool execution request to the MCP Gateway. ```json { "tool_id": "list_models", "parameters": {}, "user_credential_id": "mcp-cred-123" } ``` -------------------------------- ### MCPServer Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents a Managed Compute Platform server. Use this structure when displaying standard server details. ```python { "server_id": "server-123", "server_name": "Research Tools", "alias": "research-mcp", "description": "Internal research tool server", "transport": "http", "url": "http://localhost:8000", "auth_type": "bearer", "mcp_access_groups": ["ag-1"], "allowed_tools": ["search", "summarize"], "approval_status": "approved" } ``` -------------------------------- ### MCPCredential Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an MCP Credential resource. ```json { "id": "mcp-cred-123", "name": "User API Key", "type": "api_key", "user_id": "user-123" } ``` -------------------------------- ### MCPHealth Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an MCP Health resource. ```json { "service": "MCP Gateway", "status": "operational", "details": "All systems nominal." } ``` -------------------------------- ### Get Budget Settings Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the current budget settings for the account. ```python get_budget_settings() ``` -------------------------------- ### Invoke LiteLLM Tool via Python Client Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/README.md Example of using the LiteLLMClient to list models. Requires importing LiteLLMClient and settings. ```python from src.litellm_client import LiteLLMClient from src.config import settings client = LiteLLMClient( base_url=settings.proxy_url, api_key=settings.get_api_key_value() ) models = await client.list_models() print(models) ``` -------------------------------- ### Listing Available Models Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example of calling the `list_models` method on `LiteLLMClient` to retrieve a list of available models. ```python models = await client.models.list_models() print(models) ``` -------------------------------- ### MCPSubmission Data Structure Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON representation of an MCP Submission resource, likely for task execution. ```json { "id": "sub-xyz", "tool_id": "list_models", "status": "pending", "created_at": "2023-01-01T12:00:00Z" } ``` -------------------------------- ### Getting Model Information Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Demonstrates how to fetch detailed information about a specific model using its ID. ```python model_info = await client.models.get_model_info(model_id="gpt-3.5-turbo") print(model_info) ``` -------------------------------- ### SpendRecord Object Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Example of a spend record object with standard fields. Captures details of a single API request's cost and token usage. ```json { "request_id": "req-xyz", "call_type": "chat", "api_key": "sk-…", "user": "user-123", "team_id": "team-1", "model": "gpt-4o", "total_tokens": 2048, "spend": 0.15, "startTime": "2025-06-14T10:00:00Z", "endTime": "2025-06-14T10:00:05Z" } ``` -------------------------------- ### ChatCompletion Object Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Example of a chat completion object adhering to OpenAI's format. Includes response ID, model, choices, and usage statistics. ```json { "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1686789200, "model": "gpt-4o", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I help you?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` -------------------------------- ### Embedding Response Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON response for an embedding request. ```json { "id": "embd-abc", "object": "embedding", "data": [ { "index": 0, "embedding": [ 0.001, 0.002, -0.001, ... ] } ], "model": "text-embedding-ada-002", "usage": { "prompt_tokens": 5, "total_tokens": 5 } } ``` -------------------------------- ### Updating an Existing Model Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example of updating the configuration or details of an existing model using its ID. ```python update_data = {"input_cost": 0.00015} await client.models.update_model(model_id="my-custom-model", data=update_data) print("Model updated successfully.") ``` -------------------------------- ### Initializing LiteLLMClient with Custom Settings Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Demonstrates initializing `LiteLLMClient` with a custom proxy URL and API key. Ensure your API key is kept secure. ```python from litellm import LiteLLMClient client = LiteLLMClient(proxy_url="http://localhost:4000", api_key="sk-12345") # Use client for API calls... ``` -------------------------------- ### MCPCredential Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents user-level credentials for an MCP server. Use this to check if a credential is set and if OAuth is enabled for a server. ```python { "server_id": "server-123", "has_credential": true, "oauth_enabled": false, "expires_at": null } ``` -------------------------------- ### Generate Key with Extras Dictionary Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/README.md Example of generating a key using an 'extras' dictionary for less common fields. ```python # Extras dict for uncommon fields key = await generate_key( key_alias="api-key-1", extras={"allow_all_keys": True, "custom_field": "value"} ) ``` -------------------------------- ### GET /model/info Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Fetches administrative information about model deployments, either for all deployments or a specific one. ```APIDOC ## GET /model/info ### Description Get admin-side model info for all deployments or one by id. ### Method GET ### Endpoint /model/info ### Parameters #### Query Parameters - **litellm_model_id** (str) - Optional - Internal deployment ID. #### Request Body None ### Response #### Success Response (200) `{"data": [...]}` (list of all deployments or single deployment) ### Status Codes 200, 401, 403 ``` -------------------------------- ### Tool Invocation for Spend Reporting Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example of invoking a tool to retrieve spend reporting data. ```python spend_report = await client.mcp_gateway.invoke_tool( tool_name="get_spend_report", tool_params={"organization_id": "org-123", "period": "monthly"} ) print(spend_report) ``` -------------------------------- ### Health Response Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON response for a health check request. ```json { "status": "ok", "checks": { "database": "healthy", "redis": "healthy" } } ``` -------------------------------- ### MCPHealth Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents the health status of an MCP server. Use this to monitor server health, latency, and any error messages. ```python { "server_id": "server-123", "server_name": "Research Tools", "status": "healthy", "last_checked": "2025-06-14T10:05:00Z", "latency_ms": 45, "error_message": null } ``` -------------------------------- ### MCP Toolset Example (Standard Fields) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Demonstrates the structure of an MCP toolset with standard fields, including its ID, name, description, included tools, and creation/update timestamps. Useful for understanding the data returned by list_mcp_toolsets(), get_mcp_toolset(), add_mcp_toolset(), and update_mcp_toolset(). ```python { "toolset_id": "toolset-1", "toolset_name": "research-tools", "description": "Research and data analysis tools", "tools": [ {"server_id": "server-123", "name": "search"}, {"server_id": "server-456", "name": "summarize"} ], "created_at": "2025-06-01T00:00:00Z", "updated_at": "2025-06-14T10:00:00Z" } ``` -------------------------------- ### GET /v1/mcp/toolsets Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Lists all available MCP toolsets. Toolsets are collections of tools that can be managed together. ```APIDOC ## GET /v1/mcp/toolsets ### Description List MCP toolsets. ### Method GET ### Endpoint /v1/mcp/toolsets ### Response #### Success Response (200) - **List of toolset dicts** - A list where each element is a dictionary representing an MCP toolset. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Get Model Info Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves admin-side model information for all deployments or a specific one by its LiteLLM ID. ```python all_models = await get_model_info() one_model = await get_model_info(litellm_model_id="123e4567") ``` -------------------------------- ### Create a Virtual Key Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/README.md Example of creating a new virtual API key with specified models, budget, and user ID using the LiteLLM client. ```python from src.litellm_client import LiteLLMClient key = await client.generate_key( key_alias="prod-api-key", models=["gpt-4o", "claude-3-sonnet"], max_budget=1000.0, budget_duration="monthly", user_id="user-123" ) print(f"New key: {key['token']}") ``` -------------------------------- ### List Models with Minimal Response Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/README.md Example of listing models with a minimal response verbosity. Can be called via the client or directly as an MCP tool. ```python models = await client.list_models() # Calls server.list_models() # Or via MCP tool directly (in Claude) # tool: list_models, params: {"verbosity": "minimal"} ``` -------------------------------- ### UpdateKeyRequest Body Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example JSON payload for updating an existing API key. ```json { "name": "my-updated-key", "scopes": ["read"] } ``` -------------------------------- ### Get Budget Information Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves budget information by a list of budget IDs. This is a batch lookup operation. ```python get_budget_info(budget_ids=["budget_1", "budget_2"]) ``` -------------------------------- ### Get Public Model Hub Info Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Fetch metadata for the Model Hub, including title, description, and useful links. ```python async def get_public_hub_info(self) -> dict: ``` ```python info = await client.get_public_hub_info() print(info.get("title")) # Model Hub title ``` -------------------------------- ### GET /v1/mcp/tools Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Lists all available tools from registered MCP servers. This can be filtered by a specific server ID. ```APIDOC ## GET /v1/mcp/tools ### Description List tools from registered MCP servers. ### Method GET ### Endpoint /v1/mcp/tools ### Parameters #### Query Parameters - **server_id** (str) - Optional - Filter tools by a specific MCP server ID. ### Response #### Success Response (200) - **List of MCP tool dicts** - A list where each element is a dictionary representing an MCP tool. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Response Filtering Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Illustrates how to use response filtering to select specific fields from a tool's output. This is controlled by the `RESPONSE_FIELDS` mapping. ```python # Assuming RESPONSE_FIELDS is configured elsewhere filtered_response = await client.mcp_gateway.invoke_tool( tool_name="get_model_info", tool_params={"model_id": "gpt-3.5-turbo"}, response_fields=["id", "input_cost"] ) print(filtered_response) ``` -------------------------------- ### Model Type Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents a model with its ID, object type, owner, and creation timestamp. Useful for listing and retrieving model information. ```python { "id": "gpt-4o", "object": "model", "owned_by": "openai", "created": 1609459200 } ``` -------------------------------- ### Tool Invocation for MCP Gateway Server Management Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Example of invoking a tool to manage MCP gateway servers, such as updating server details. ```python server_update_result = await client.mcp_gateway.invoke_tool( tool_name="update_mcp_server", tool_params={"server_id": "gateway-1", "data": {"url": "http://new-gateway.example.com"}} ) print(server_update_result) ``` -------------------------------- ### Creating a New Budget Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Sets up a new budget, likely for tracking expenses. ```python new_budget_data = {"name": "Q3 Marketing Budget", "amount": 5000.0, "currency": "USD"} await client.budgets.create_budget(data=new_budget_data) print("Budget created.") ``` -------------------------------- ### Configuration using .env File Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/configuration.md Sets LiteLLM MCP server configuration by creating a .env file in the project root. All variables are optional except LITELLM_API_KEY. ```bash LITELLM_PROXY_URL=http://localhost:4000 LITELLM_API_KEY=sk-your-api-key LITELLM_TRANSPORT=stdio LITELLM_TIMEOUT_SECONDS=30 LITELLM_MAX_RETRIES=2 ``` -------------------------------- ### MCPTool Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents a tool available on an MCP server. Use this structure to display tool information, including its associated server and input schema. ```python { "name": "search", "description": "Search the knowledge base", "server_id": "server-123", "inputSchema": { "type": "object", "properties": { "query": { "type": "string", "description": "Search query" } }, "required": ["query"] } } ``` -------------------------------- ### GET /key/info Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Retrieves information about a specific virtual key. If no key is provided, it returns information about the caller's own key. ```APIDOC ## GET /key/info ### Description Get info about a key. ### Method GET ### Endpoint /key/info ### Parameters #### Query Parameters - **key** (str) - Optional - The key to get information for. If omitted, returns the caller's own key. - **verbosity** (str) - Optional - Verbosity level (defaults to 'standard'). ### Response #### Success Response (200) - **Key info dict** #### Error Response - 401 - 403 - 404 ### Note Master key returns 404; test with a virtual key instead ``` -------------------------------- ### Listing Credentials Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Fetches a list of configured credentials. ```python credentials = await client.credentials.list_credentials() print(credentials) ``` -------------------------------- ### Initialize LiteLLMClient Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Initializes an async HTTP client for LiteLLM proxy operations. Requires base URL and API key. Supports optional timeout and retry settings. ```python class LiteLLMClient: def __init__( self, base_url: str, api_key: str, timeout: float = 30.0, max_retries: int = 2, ) -> None: pass ``` ```python from src.litellm_client import LiteLLMClient from src.config import settings client = LiteLLMClient( base_url="http://localhost:4000", api_key="sk-1234567890", timeout=30.0, max_retries=2 ) ``` -------------------------------- ### Creating a New Customer Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Registers a new customer account. ```python new_customer_data = {"name": "Acme Corp", "email": "contact@acme.com"} await client.customers.create_customer(data=new_customer_data) print("Customer created.") ``` -------------------------------- ### User Type Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents a user with their ID, email, role, and associated teams/organizations. Includes spend and budget information. Standard verbosity omits some full fields. ```python { "user_id": "user-123", "user_email": "alice@example.com", "user_alias": "alice", "user_role": "admin", "teams": ["team-1"], "organizations": ["org-1"], "models": [], "max_budget": null, "spend": 10.00, "blocked": false } ``` -------------------------------- ### Get MCP OpenAPI Registry Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the MCP OpenAPI registry. Corresponds to the GET /v1/mcp/openapi-registry API endpoint. ```python get_mcp_openapi_registry() -> dict ``` -------------------------------- ### LiteLLMClient Constructor Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Initializes an async HTTP client for LiteLLM proxy operations. Requires base URL and API key, with optional timeout and retry settings. ```APIDOC ## LiteLLMClient Constructor ### Description Initializes an async HTTP client for LiteLLM proxy operations. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method `__init__` (Constructor) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `base_url` | `str` | Yes | — | LiteLLM proxy base URL (e.g., `http://localhost:4000`); trailing `/` is stripped | | `api_key` | `str` | Yes | — | Bearer token (master or virtual key); sent as `Authorization: Bearer ` | | `timeout` | `float` | No | `30.0` | HTTP request timeout in seconds (passed to `httpx.AsyncClient`) | | `max_retries` | `int` | No | `2` | Retry budget for transient errors (408, 429, 500–504); 0 means no retry | ### Request Example ```python from src.litellm_client import LiteLLMClient client = LiteLLMClient( base_url="http://localhost:4000", api_key="sk-1234567890", timeout=30.0, max_retries=2 ) ``` ### Response N/A (Constructor) ``` -------------------------------- ### Get MCP Client IP Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the client's IP address. Corresponds to the GET /v1/mcp/network/client-ip API endpoint. ```python get_mcp_client_ip() -> dict ``` -------------------------------- ### Health Object Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Example of a health object detailing deployment status. Includes counts of healthy and unhealthy endpoints and their details. ```json { "healthy_count": 2, "unhealthy_count": 0, "healthy_endpoints": [ { "name": "gpt-4o", "model_name": "gpt-4o", "litellm_params": {}, "status": "healthy" } ], "unhealthy_endpoints": [] } ``` -------------------------------- ### Get MCP Registry Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the MCP registry. This endpoint is optional and may return a 404 if not available. Corresponds to GET /v1/mcp/registry.json. ```python get_mcp_registry() -> dict ``` -------------------------------- ### Key Type Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Details an API key including its alias, spend, budget, and associated models. The raw token is included but should not be logged. Standard verbosity omits some full fields for brevity. ```python { "token": "sk-...", "key_name": "key_xyz", "key_alias": "api-key-1", "spend": 25.50, "max_budget": 100.0, "models": ["gpt-4o"], "user_id": "user-123", "team_id": null, "expires": "2025-12-31T23:59:59Z", "blocked": false } ``` -------------------------------- ### GET /v1/mcp/server/{server_id} Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Retrieves details for a specific MCP server identified by its ID. Use this to get information about a particular server. ```APIDOC ## GET /v1/mcp/server/{server_id} ### Description Get MCP server by id. ### Method GET ### Endpoint /v1/mcp/server/{server_id} ### Parameters #### Path Parameters - **server_id** (str) - Required - The unique identifier of the MCP server. ### Response #### Success Response (200) - **MCP server dict** - A dictionary containing the details of the specified MCP server. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Embedding Object Example Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Example of an embedding object, typically returned as a list. Contains model information, embedding vectors, and usage statistics. ```json { "object": "list", "model": "text-embedding-3-small", "data": [ { "index": 0, "embedding": [0.123, -0.456, ...] } ], "usage": { "prompt_tokens": 10, "total_tokens": 10 } } ``` -------------------------------- ### POST /model/new Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Registers a new model deployment with the LiteLLM proxy. ```APIDOC ## POST /model/new ### Description Register a new model deployment. ### Method POST ### Endpoint /model/new ### Parameters #### Query Parameters None #### Request Body - **model_name** (str) - Required - The name of the model. - **litellm_params** (dict) - Required - Parameters for LiteLLM. - **model_info** (dict) - Required - Information about the model. ### Response #### Success Response (201) Created deployment dict ### Status Codes 201 (created), 400 (invalid), 401, 403 ``` -------------------------------- ### MCPSubmission Example (Standard Verbosity) Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/types.md Represents a submission for an MCP server, including details about the server and its approval status. Use this for tracking server submissions. ```python { "server_id": "server-456", "server_name": "Community Tool", "alias": "community-mcp", "transport": "http", "url": "http://example.com/mcp", "approval_status": "pending", "submitted_by": "user@example.com", "submitted_at": "2025-06-14T10:00:00Z" } ``` -------------------------------- ### Get MCP OAuth User Credential Status Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the status of OAuth user credentials for a specific MCP server. Corresponds to GET /v1/mcp/server/{id}/oauth-user-credential/status. ```python get_mcp_oauth_user_credential_status(server_id: str) -> dict ``` -------------------------------- ### Creating a New Project Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Creates a new project, likely within an organization. ```python new_project_data = {"name": "Alpha Project", "organization_id": "tech-solutions"} await client.projects.create_project(data=new_project_data) print("Project created.") ``` -------------------------------- ### Get Model Info by LiteLLM ID Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Fetches admin-side model information for all deployments or a specific one using its internal LiteLLM ID via GET /model/info. Returns the upstream payload. ```python async def get_model_info(self, litellm_model_id: Optional[str] = None) -> dict: pass ``` ```python all_models = await client.get_model_info() one_model = await client.get_model_info(litellm_model_id="123e4567") ``` -------------------------------- ### Initializing LiteLLMClient Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Basic initialization of the `LiteLLMClient` with default settings. This client is used for making asynchronous HTTP requests to the LiteLLM API. ```python from litellm import LiteLLMClient client = LiteLLMClient() # Use client for API calls... ``` -------------------------------- ### GET /credentials/by_name/{credential_name} Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Retrieves a specific credential by its name. ```APIDOC ## GET /credentials/by_name/{credential_name} ### Description Get a credential by name. ### Method GET ### Endpoint /credentials/by_name/{credential_name} ### Parameters #### Path Parameters - **credential_name** (str) - Required - The name of the credential to retrieve. ### Response #### Success Response (200) - **Credential dict** - A dictionary containing the details of the specified credential. ### Status Codes - 200 - 401 - 403 - 404 ``` -------------------------------- ### Get Health Backlog Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the health backlog information for the system. ```python check_health_backlog() ``` -------------------------------- ### GET /public/model_hub Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Retrieves a list of models published to the public Model Hub. ```APIDOC ## GET /public/model_hub ### Description List models published to the public Model Hub. ### Method GET ### Endpoint /public/model_hub ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) Upstream payload (list or dict) ### Status Codes 200, 401, 403 ``` -------------------------------- ### Accessing Configuration Settings Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Shows how to access and check for the presence of API key configuration settings using Pydantic's `BaseSettings`. ```python from litellm import settings if settings.has_api_key: print("API key is configured.") else: print("API key is not configured.") ``` -------------------------------- ### Tool Invocation with Parameters Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Shows how to invoke an MCP tool that requires specific parameters. ```python tool_result = await client.mcp_gateway.invoke_tool( tool_name="get_model", tool_params={"model_id": "gpt-3.5-turbo"} ) print(tool_result) ``` -------------------------------- ### get_user_daily_activity Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Get daily activity for a specific internal user within a date range. ```APIDOC ## GET /user/daily/activity ### Description Get daily activity for an internal user. ### Method GET ### Endpoint /user/daily/activity ### Parameters #### Query Parameters - **user_id** (str) - Required - The ID of the user. - **start_date** (str) - Required - The start date for the activity log (YYYY-MM-DD). - **end_date** (str) - Required - The end date for the activity log (YYYY-MM-DD). ``` -------------------------------- ### Creating a New Organization Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Registers a new organization. ```python new_org_data = {"name": "Tech Solutions Inc.", "owner_email": "admin@techsolutions.com"} await client.organizations.create_organization(data=new_org_data) print("Organization created.") ``` -------------------------------- ### Get Public MCP Hub Listing Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the listing of public MCP hubs. ```python await get_public_mcp_hub() ``` -------------------------------- ### list_credentials Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Lists all provider credentials. This operation corresponds to a GET request to the /credentials endpoint. ```APIDOC ## GET /credentials ### Description List provider credentials. ### Method GET ### Endpoint /credentials ### Response #### Success Response (200) - The upstream payload (list of credential dicts). Credential values are not included — use `get_credential()` for full details. ### Request Example ```python # Usage: creds = await client.list_credentials() for cred in creds: print(cred["credential_name"]) ``` ``` -------------------------------- ### get_public_hub_info Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Get Model Hub metadata, including title, description, and useful links. ```APIDOC ## GET /public/model_hub/info ### Description Get Model Hub metadata, including title, description, and useful links. ### Method GET ### Endpoint /public/model_hub/info ### Response #### Success Response (200) - **dict** - Hub info dict. ### Response Example ```json { "title": "LiteLLM Model Hub", "description": "A central place for discovering and managing models.", "useful_links": { "Documentation": "https://docs.litellm.ai" } } ``` ``` -------------------------------- ### Listing Projects Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Fetches a list of projects associated with organizations or users. ```python projects = await client.projects.list_projects() print(projects) ``` -------------------------------- ### Listing Customers Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Fetches a list of customer accounts. ```python customers = await client.customers.list_customers() print(customers) ``` -------------------------------- ### GET /public/litellm_model_cost_map Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/endpoints.md Retrieves LiteLLM's static map of model costs and capabilities. ```APIDOC ## GET /public/litellm_model_cost_map ### Description Get LiteLLM's static model cost and capability map. ### Method GET ### Endpoint /public/litellm_model_cost_map ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) Large cost/capability mapping dict (~1MB) ### Status Codes 200, 401, 403 ``` -------------------------------- ### Generate Key with Common Fields Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/README.md Example of generating a key using named arguments for common fields like alias, models, and max budget. ```python # Named args for common fields key = await generate_key( key_alias="api-key-1", models=["gpt-4o"], max_budget=100.0 ) ``` -------------------------------- ### get_budget_settings Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Retrieves the current budget settings configuration. ```APIDOC ## GET /budget/settings ### Description Get budget settings. ### Method GET ### Endpoint /budget/settings ``` -------------------------------- ### get_user_info Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/tools.md Get information about an internal user. If `user_id` is omitted, returns the caller's information. ```APIDOC ## GET /user/info ### Description Get info about an internal user. If `user_id` omitted, returns caller's info. ### Method GET ### Endpoint /user/info ### Parameters #### Query Parameters - **user_id** (Optional[str]) - Description: The ID of the user to get info for. If omitted, returns caller's info. - **verbosity** (str) - Optional - Verbosity level ('standard' or 'detailed'). Defaults to 'standard'. ``` -------------------------------- ### get_model Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Retrieves a single model entry from the OpenAI-compatible models endpoint (`GET /v1/models/{model_id}`). ```APIDOC ## get_model ### Description Get a single model entry from the OpenAI-compatible models endpoint (`GET /v1/models/{model_id}`). ### Method `get_model(model_id: str)` ### Endpoint `GET /v1/models/{model_id}` ### Parameters #### Path Parameters - **model_id** (str) - Required - OpenAI-style model id (e.g., `gpt-4o`) ### Request Example ```python model = await client.get_model("gpt-4o") print(model["owned_by"]) ``` ### Response #### Success Response - **Model dict**: Contains model details. ``` -------------------------------- ### Access Module Globals Settings Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/configuration.md Accesses the singleton instance of LiteLLMSettings to retrieve configuration values like proxy URL and timeout. This instance is loaded at module import time. ```python from src.config import settings print(settings.proxy_url) # http://localhost:4000 print(settings.timeout_seconds) # 30.0 ``` -------------------------------- ### Add New Model Deployment Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Registers a new model deployment using POST /model/new. Requires model name, LiteLLM parameters for routing, and model information metadata. ```python async def add_model( self, model_name: str, litellm_params: dict, model_info: dict, ) -> dict: pass ``` ```python deployment = await client.add_model( model_name="gpt-4o", litellm_params={ "model": "openai/gpt-4o", "api_key": "sk-1234567890" }, model_info={ "id": "deployment-123", "db_model": False } ) ``` -------------------------------- ### Getting Model Cost Map Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Retrieves the cost mapping for various models from the model hub. ```python cost_map = await client.model_hub.get_model_cost_map() print(cost_map) ``` -------------------------------- ### MCP Gateway Server/Toolset Extras Argument Source: https://github.com/tetra-2023/litellm-mcp/blob/main/README.md Illustrates the use of the 'extras' argument for less common fields in server and toolset operations. ```python add_mcp_server(..., extras: dict) update_mcp_server(..., extras: dict) register_mcp_server(..., extras: dict) test_mcp_connection(..., extras: dict) ``` -------------------------------- ### Discovering MCP Gateway Tools Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Discovers available tools exposed by MCP gateway servers. ```python discovered_tools = await client.mcp_gateway.discover_tools() print(discovered_tools) ``` -------------------------------- ### Tool Invocation for MCP Gateway Toolset Management Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/MANIFEST.md Demonstrates invoking a tool for managing MCP gateway toolsets, such as creating a new toolset. ```python toolset_create_result = await client.mcp_gateway.invoke_tool( tool_name="create_mcp_toolset", tool_params={"name": "default-tools", "tool_ids": ["list_models", "get_model"]} ) print(toolset_create_result) ``` -------------------------------- ### get_credential Source: https://github.com/tetra-2023/litellm-mcp/blob/main/_autodocs/client.md Retrieves a specific credential by its name. This operation corresponds to a GET request to the /credentials/by_name/{credential_name} endpoint. ```APIDOC ## GET /credentials/by_name/{credential_name} ### Description Get a credential by name. ### Method GET ### Endpoint /credentials/by_name/{credential_name} ### Parameters #### Path Parameters - **credential_name** (str) - Required - Name of the stored credential ### Response #### Success Response (200) - **credential_name** (str) - Name of the stored credential. - **credential_info** (dict) - Information about the credential. - **credential_values** (dict) - Credential values (if verbosity='full'). ### Request Example ```python # Usage: cred = await client.get_credential("openai-prod") print(cred["credential_name"]) ``` ```