Skip to main content
Glama

list_models

Retrieve all available models for use with the Grok API to facilitate seamless integration and selection for AI tasks.

Instructions

List all models available for use with the Grok API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for listing models. It makes a request to the 'models' endpoint via grokRequest and parses the response using ListModelsResponseSchema.
    export async function listModels(): Promise< z.infer<typeof ListModelsResponseSchema> > { const response = await grokRequest("models"); return ListModelsResponseSchema.parse(response); }
  • Zod schema for validating the list models API response, containing an array of ModelSchema objects.
    export const ListModelsResponseSchema = z.object({ object: z.string(), data: z.array(ModelSchema), });
  • Zod schema defining the structure of a single model object, used within ListModelsResponseSchema.
    export const ModelSchema = z.object({ id: z.string(), created: z.number().optional(), object: z.string(), owned_by: z.string().optional(), });
  • Empty Zod schema for list models input options (no parameters required).
    export const ListModelsOptionsSchema = z.object({});
  • index.ts:69-81 (registration)
    Tool registration in the FastMCP server. Specifies the tool name, description, input schema, and an execute handler that calls the core listModels function and stringifies the result.
    server.addTool({ name: "list_models", description: "List all models available for use with the Grok API", parameters: models.ListModelsOptionsSchema, execute: async () => { try { const result = await models.listModels(); return JSON.stringify(result, null, 2); } catch (err) { handleError(err); } }, });

Other Tools

Related Tools

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/BrewMyTech/grok-mcp'

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