UNPKG

@vibe-kit/grok-cli

Version:

An open-source AI agent that brings the power of Grok directly into your terminal.

50 lines (49 loc) 1.51 kB
import type { ChatCompletionMessageParam } from "openai/resources/chat"; export type GrokMessage = ChatCompletionMessageParam; export interface GrokTool { type: "function"; function: { name: string; description: string; parameters: { type: "object"; properties: Record<string, any>; required: string[]; }; }; } export interface GrokToolCall { id: string; type: "function"; function: { name: string; arguments: string; }; } export interface SearchParameters { mode?: "auto" | "on" | "off"; } export interface SearchOptions { search_parameters?: SearchParameters; } export interface GrokResponse { choices: Array<{ message: { role: string; content: string | null; tool_calls?: GrokToolCall[]; }; finish_reason: string; }>; } export declare class GrokClient { private client; private currentModel; private defaultMaxTokens; constructor(apiKey: string, model?: string, baseURL?: string); setModel(model: string): void; getCurrentModel(): string; chat(messages: GrokMessage[], tools?: GrokTool[], model?: string, searchOptions?: SearchOptions): Promise<GrokResponse>; chatStream(messages: GrokMessage[], tools?: GrokTool[], model?: string, searchOptions?: SearchOptions): AsyncGenerator<any, void, unknown>; search(query: string, searchParameters?: SearchParameters): Promise<GrokResponse>; }