{"record":{"id":"1d9db73fadd48efc","repo":"mem0ai/mem0","slug":"together-llm-failed-message","errorCode":null,"errorMessage":"Together LLM failed: ${message}","messagePattern":"Together LLM failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/llms/together.ts","lineNumber":31,"sourceCode":"      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 {\n      return await super.generateResponse(messages, responseFormat, tools);\n    } catch (err) {\n      const message = err instanceof Error ? err.message : String(err);\n      throw new Error(`Together LLM failed: ${message}`);\n    }\n  }\n\n  async generateChat(messages: Message[]): Promise<LLMResponse> {\n    try {\n      return await super.generateChat(messages);\n    } catch (err) {\n      const message = err instanceof Error ? err.message : String(err);\n      throw new Error(`Together LLM failed: ${message}`);\n    }\n  }\n}\n","sourceCodeStart":13,"sourceCodeEnd":44,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/llms/together.ts#L13-L44","documentation":"Thrown by the Together AI LLM wrapper in the OSS TypeScript SDK when the underlying OpenAI-compatible call to Together's API fails while generating a structured response (generateResponse). The wrapper catches any error from the parent OpenAILLM implementation and re-throws it prefixed with 'Together LLM failed' plus the original message. The root cause is almost always an HTTP, auth, model, or network problem reported by the Together API.","triggerScenarios":"Calling memory.add(), memory.search(), or any Memory pipeline step that invokes the LLM while config.llm.provider is 'together', and the POST to https://api.together.xyz/v1/chat/completions fails: invalid/expired TOGETHER_API_KEY, unknown model name in config.llm.config.model, malformed responseFormat, rate limiting, or a network/DNS failure.","commonSituations":"Setting an incorrect model id (e.g. a typo or a deprecated Together model), missing TOGETHER_API_KEY in the environment where the Node process runs, exceeding Together rate limits under load, or routing through a custom baseURL that is unreachable. Also triggered when Together returns a non-OpenAI-shaped error payload that the parent class surfaces as a generic Error.","solutions":["Check the original message appended after 'Together LLM failed:' — it carries Together's HTTP status/body (401 = bad key, 404 = bad model, 429 = rate limit).","Verify the API key: set config.llm.config.apiKey explicitly or export TOGETHER_API_KEY in the process environment.","Verify the model id is a current Together model (e.g. 'meta-llama/Llama-3.3-70B-Instruct-Turbo'); fix config.llm.config.model.","If rate-limited, add backoff/retry around the Memory call or reduce concurrency.","If using a custom baseURL, confirm it is reachable from the runtime (curl it from the same host/container)."],"exampleFix":"// before\nconst memory = new Memory({\n  llm: { provider: 'together', config: { model: 'llama-3.3-70b' } }, // wrong id, 404 at call time\n});\nawait memory.add('hello', { userId: 'u1' }); // throws Together LLM failed: 404 ...\n\n// after\nconst memory = new Memory({\n  llm: {\n    provider: 'together',\n    config: {\n      apiKey: process.env.TOGETHER_API_KEY,\n      model: 'meta-llama/Llama-3.3-70B-Instruct-Turbo',\n    },\n  },\n});","handlingStrategy":"retry","validationCode":"import Together from 'together-ai';\nasync function assertTogetherReachable(apiKey: string, model: string) {\n  const client = new Together({ apiKey });\n  await client.models.retrieve(model); // 404 here means bad model id, before Memory runs\n}","typeGuard":"function isTransientLlmError(err: unknown): boolean {\n  const msg = err instanceof Error ? err.message : String(err);\n  return /Together LLM failed:.*(429|500|502|503|504|ECONNRESET|ETIMEDOUT|fetch failed)/.test(msg);\n}","tryCatchPattern":"try {\n  await memory.add(text, { filters: { userId } });\n} catch (err) {\n  const msg = err instanceof Error ? err.message : String(err);\n  if (/Together LLM failed:/.test(msg) && /401|invalid api key/i.test(msg)) {\n    // config problem: surface to operator, do not retry\n    throw new Error('Together credentials invalid — check TOGETHER_API_KEY');\n  }\n  if (/429|5\\d\\d|ETIMEDOUT|fetch failed/.test(msg)) {\n    await backoffRetry(() => memory.add(text, { filters: { userId } }));\n  } else throw err;\n}","preventionTips":["Set TOGETHER_API_KEY via your deployment's env management, not ad-hoc shells.","Pin model ids that exist on the day you ship; re-verify after Together deprecations.","Smoke-test the key and model with a direct API call at service startup."],"tags":["llm","together","api-key","typescript","oss-sdk"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}