Skip to main content
Glama
embed.py656 B
import os from typing import List from openai import OpenAI class Embedder: def __init__(self, model: str = "text-embedding-3-large", api_key: str | None = None): self.model = model self.client = OpenAI(api_key=api_key or os.getenv("OPENAI_API_KEY")) def embed(self, texts: List[str]) -> List[List[float]]: # OpenAI supports batching; keep batches reasonable out = [] B = 64 for i in range(0, len(texts), B): batch = texts[i:i+B] resp = self.client.embeddings.create(model=self.model, input=batch) out.extend([d.embedding for d in resp.data]) return out

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/Nithishkaranam2002/Finrag--mcp'

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