Skip to main content
Glama
xai.js1.09 kB
/** * xai.js * AI provider implementation for xAI models using Vercel AI SDK. */ import { createXai } from '@ai-sdk/xai'; import { BaseAIProvider } from './base-provider.js'; export class XAIProvider extends BaseAIProvider { constructor() { super(); this.name = 'xAI'; } /** * Returns the environment variable name required for this provider's API key. * @returns {string} The environment variable name for the xAI API key */ getRequiredApiKeyName() { return 'XAI_API_KEY'; } /** * Creates and returns an xAI client instance. * @param {object} params - Parameters for client initialization * @param {string} params.apiKey - xAI API key * @param {string} [params.baseURL] - Optional custom API endpoint * @returns {Function} xAI client function * @throws {Error} If API key is missing or initialization fails */ getClient(params) { try { const { apiKey, baseURL } = params; return createXai({ apiKey, baseURL: baseURL || 'https://api.x.ai/v1' }); } catch (error) { this.handleError('client initialization', error); } } }

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/eyaltoledano/claude-task-master'

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