Skip to main content
Glama

list_models

Retrieve available Grok AI models from xAI to check model IDs, ownership details, and creation dates for selecting appropriate models.

Instructions

Gets a list of all available Grok models from xAI. This is super handy when you need to see what models are available to use. You'll get the model ID, who owns it, and when it was created. Perfect for checking if a new model is available or verifying what models you can access. Returns a formatted string with all the model details.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • The main handler function for the list_models tool. It fetches the list of available Grok models from the xAI API using create_client, parses the response, formats model information (ID, owner, creation date), and returns a formatted string list.
    @mcp.tool() async def list_models() -> str: """ Gets a list of all available Grok models from xAI. This is super handy when you need to see what models are available to use. You'll get the model ID, who owns it, and when it was created. Perfect for checking if a new model is available or verifying what models you can access. Returns a formatted string with all the model details. """ client = create_client() response = await client.get("/models") response.raise_for_status() data = response.json() models_info = [] for model in data.get("data", []): model_id = model.get("id", "") created_timestamp = model.get("created", 0) owned_by = model.get("owned_by", "") # Convert Unix timestamp to date if created_timestamp: created_date = datetime.fromtimestamp(created_timestamp).strftime("%Y-%m-%d") else: created_date = "" models_info.append(f"- {model_id} (Owner: {owned_by}, Created: {created_date})") await client.aclose() return "Available Grok Models:\n" + "\n".join(models_info)
  • Supporting utility function create_client() used in list_models to instantiate the httpx client for making API requests to xAI.
    def create_client( timeout: float = 120.0, use_state: bool = False, api_key: Optional[str] = None ) -> httpx.AsyncClient: base_url = XAI_STATE_URL if use_state else XAI_URL key = api_key or get_api_key() return httpx.AsyncClient( base_url=base_url, headers={ "Authorization": f"Bearer {key}", "Content-Type": "application/json" }, timeout=timeout )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/merterbak/Grok-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server