{"record":{"id":"eed86ed97a1052de","repo":"Fosowl/agenticSeek","slug":"together-ai-api-error-str-e","errorCode":null,"errorMessage":"Together AI API error: {str(e)}","messagePattern":"Together AI API error: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/llm_provider.py","lineNumber":327,"sourceCode":"        \"\"\"\n        from together import Together\n        client = Together(api_key=self.api_key)\n        if self.is_local:\n            raise Exception(\"Together AI is not available for local use. Change config.ini\")\n\n        try:\n            response = client.chat.completions.create(\n                model=self.model,\n                messages=history,\n            )\n            if response is None:\n                raise Exception(\"Together AI response is empty.\")\n            thought = response.choices[0].message.content\n            if verbose:\n                print(thought)\n            return thought\n        except Exception as e:\n            raise Exception(f\"Together AI API error: {str(e)}\") from e\n\n    def deepseek_fn(self, history, verbose=False):\n        \"\"\"\n        Use deepseek api to generate text.\n        \"\"\"\n        client = OpenAI(api_key=self.api_key, base_url=\"https://api.deepseek.com\")\n        if self.is_local:\n            raise Exception(\"Deepseek (API) is not available for local use. Change config.ini\")\n        try:\n            response = client.chat.completions.create(\n                model=self.model,\n                messages=history,\n                stream=False\n            )\n            thought = response.choices[0].message.content\n            if verbose:\n                print(thought)\n            return thought","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/Fosowl/agenticSeek/blob/ae57a2357745a9706cb12d0fd76d954c84d166fa/sources/llm_provider.py#L309-L345","documentation":"together_fn wraps any failure from the Together AI chat completions call in a generic Exception prefixed 'Together AI API error:'. The library re-raises with `from e` so the underlying cause (auth, network, model name, rate limit) is preserved in __cause__. It is a catch-all wrapper, so the real problem must be read from the chained message.","triggerScenarios":"Any exception raised inside together_fn after the try block begins: Together HTTP client errors (invalid/missing API key, unknown model name, rate limiting, 5xx), network failures, or an empty response (choices missing).","commonSituations":"Expired or wrong TOGETHER_API_KEY in config.ini; model string like 'mistralai/Mixtral-8x7B' misspelled; free-tier rate limit hit; Together service outage; corporate proxy blocking api.together.xyz.","solutions":["Read the chained exception (__cause__) message to identify the underlying Together API failure","Verify the Together API key in config.ini is set and valid (test with curl against api.together.xyz)","Confirm self.model matches an exact Together model slug (e.g. 'mistralai/Mixtral-8x7B-Instruct-v0.1')","Retry with backoff if the message indicates 429/5xx; check status.together.ai for outages","Check network/proxy access to api.together.xyz from the host"],"exampleFix":"// before\nthought = provider.together_fn(history)\n// after\ntry:\n    thought = provider.together_fn(history)\nexcept Exception as e:\n    logging.error(f\"Together call failed: {e}; cause: {e.__cause__}\")\n    raise","handlingStrategy":"try-catch","validationCode":"import os\ndef validate_together(provider):\n    assert provider.api_key and provider.api_key.startswith((\"together-\", \"sk-\")), \"Set a valid Together API key in config.ini\"\n    assert provider.model and \"/\" in provider.model, f\"Model '{provider.model}' is not a Together slug (expected 'org/model')\"","typeGuard":"def is_together_slug(model: str) -> bool:\n    return bool(model) and \"/\" in model and not model.startswith(\"gpt-\")","tryCatchPattern":"try:\n    thought = provider.together_fn(history)\nexcept Exception as e:\n    cause = e.__cause__\n    if cause and \"401\" in str(cause):\n        fix_api_key()\n    elif cause and \"429\" in str(cause):\n        schedule_retry_with_backoff()\n    else:\n        raise","preventionTips":["Pre-validate the Together model slug and API key before calling","Always inspect e.__cause__ — the wrapper hides the real HTTP failure","Add retry-with-backoff for 429/5xx causes","Monitor Together status page during outages"],"tags":["api","network","together-ai","error-wrapping"],"backgroundTag":"llm-api-request-failed","analyzedSha":"ae57a2357745a9706cb12d0fd76d954c84d166fa","analyzedAt":"2026-08-30T02:49:05.834Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}