{"record":{"id":"b365bfad5b08fc28","repo":"mem0ai/mem0","slug":"together-api-key-is-required-b365bf","errorCode":null,"errorMessage":"Together API key is required","messagePattern":"Together API key is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/llms/together.ts","lineNumber":9,"sourceCode":"import { OpenAILLM } from \"./openai\";\nimport { LLMConfig, Message } from \"../types\";\nimport { LLMResponse } from \"./base\";\n\nexport class TogetherLLM extends OpenAILLM {\n  constructor(config: LLMConfig) {\n    const apiKey = config.apiKey || process.env.TOGETHER_API_KEY;\n    if (!apiKey) {\n      throw new Error(\"Together API key is required\");\n    }\n    super({\n      ...config,\n      apiKey,\n      baseURL:\n        config.baseURL ||\n        process.env.TOGETHER_API_BASE ||\n        \"https://api.together.ai/v1\",\n      model: config.model || \"MiniMaxAI/MiniMax-M3\",\n    });\n  }\n\n  async generateResponse(\n    messages: Message[],\n    responseFormat?: { type: string },\n    tools?: any[],\n  ): Promise<string | LLMResponse> {\n    try {","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/llms/together.ts#L1-L27","documentation":"Thrown synchronously by the TogetherLLM constructor when no Together AI API key is resolved. The provider checks config.apiKey, then the TOGETHER_API_KEY environment variable, and throws when both are missing — the fail-fast guard before building the OpenAI-compatible client for api.together.ai.","triggerScenarios":"Instantiating TogetherLLM (provider 'together') with apiKey absent/empty and TOGETHER_API_KEY unset at construction time.","commonSituations":"Key not created at api.together.ai/settings/api-keys; env var set only in local shell but missing in CI/production; dotenv loaded after Memory construction; key name typo (TOGETHERAI_API_KEY).","solutions":["Export TOGETHER_API_KEY with a key from the Together settings page.","Or pass it explicitly: llm: { provider: 'together', config: { apiKey: process.env.TOGETHER_API_KEY } }.","Load dotenv before constructing Memory.","Add TOGETHER_API_KEY to deployment/CI secrets."],"exampleFix":"// before\nconst mem = new Memory({ llm: { provider: 'together', config: {} } });\n// throws: Together API key is required\n\n// after\nimport 'dotenv/config';\nconst mem = new Memory({\n  llm: { provider: 'together', config: { apiKey: process.env.TOGETHER_API_KEY! } },\n});","handlingStrategy":"validation","validationCode":"function assertTogetherKey(cfg: LLMConfig) {\n  if (!cfg.apiKey && !process.env.TOGETHER_API_KEY) {\n    throw new Error('TOGETHER_API_KEY not set — create one at api.together.ai/settings/api-keys');\n  }\n}","typeGuard":"const hasTogetherKey = (cfg: LLMConfig): boolean => Boolean(cfg.apiKey || process.env.TOGETHER_API_KEY);","tryCatchPattern":"try { new TogetherLLM(config); } catch (e) {\n  if ((e as Error).message === 'Together API key is required') throw new StartupConfigError('TOGETHER_API_KEY missing');\n  throw e;\n}","preventionTips":["Export TOGETHER_API_KEY (exact name) or pass apiKey in config.","Load dotenv before constructing Memory.","Validate provider-specific env vars in a boot schema check."],"tags":["together","llm","api-key","config","env","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}