Skip to main content
Glama
embeddings.service.ts740 B
import OpenAI from 'openai'; export class EmbeddingsService { private readonly openai: OpenAI; private readonly model: string; constructor(model: string = 'text-embedding-3-large') { const apiKey = process.env.OPENAI_API_KEY; if (!apiKey) { throw new Error('OPENAI_API_KEY environment variable is required'); } this.openai = new OpenAI({ apiKey }); this.model = model; } async embedText(text: string): Promise<number[]> { try { const response = await this.openai.embeddings.create({ model: this.model, input: text, }); return response.data[0].embedding; } catch (error) { console.error('Error creating embedding:', error); throw 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/drewdrewH/code-graph-context'

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