{"record":{"id":"51fd0ff09a7e805b","repo":"BerriAI/litellm","slug":"oci-embedtext-accepts-at-most-oci-embed-batch-lim","errorCode":null,"errorMessage":"OCI embedText accepts at most {OCI_EMBED_BATCH_LIMIT} inputs per request (got {len(texts)}). Batch your requests.","messagePattern":"OCI embedText accepts at most (.+?) inputs per request \\(got (.+?)\\)\\. Batch your requests\\.","errorType":"exception","errorClass":"OCIError","httpStatus":400,"severity":"error","filePath":"litellm/llms/oci/embed/transformation.py","lineNumber":212,"sourceCode":"        if isinstance(input, str):\n            texts = [input]\n        elif isinstance(input, list):\n            texts = []\n            for item in input:\n                if isinstance(item, list):\n                    raise OCIError(\n                        status_code=400,\n                        message=(\n                            \"OCI embedText does not support token-array inputs. \"\n                            \"Convert token lists to strings before calling embedding().\"\n                        ),\n                    )\n                texts.append(item if isinstance(item, str) else str(item))\n        else:\n            texts = [str(input)]\n\n        if len(texts) > OCI_EMBED_BATCH_LIMIT:\n            raise OCIError(\n                status_code=400,\n                message=(\n                    f\"OCI embedText accepts at most {OCI_EMBED_BATCH_LIMIT} inputs per request \"\n                    f\"(got {len(texts)}). Batch your requests.\"\n                ),\n            )\n\n        serving_mode_type: Final = optional_params.get(\"oci_serving_mode\", \"ON_DEMAND\").upper()\n        if serving_mode_type not in {\"ON_DEMAND\", \"DEDICATED\"}:\n            raise OCIError(\n                status_code=400,\n                message=\"oci_serving_mode must be 'ON_DEMAND' or 'DEDICATED'.\",\n            )\n\n        if serving_mode_type == \"DEDICATED\":\n            endpoint_id: Final = optional_params.get(\"oci_endpoint_id\", model)\n            serving_mode = OCIServingMode(servingType=\"DEDICATED\", endpointId=endpoint_id)\n        else:","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/embed/transformation.py#L194-L230","documentation":"The OCI embedText endpoint enforces a hard per-request batch limit, which LiteLLM's OCI adapter defines as OCI_EMBED_BATCH_LIMIT = 96 (litellm/llms/oci/embed/transformation.py:56). After flattening `input` into a list of strings, if there are more than 96 texts the adapter raises this 400 error client-side instead of sending a doomed request.","triggerScenarios":"Calling litellm.embedding with an OCI embedding model and an input list longer than 96 strings, e.g. embedding a 500-document corpus in one call: `litellm.embedding(model='oci/generative-ai-cohere-embed-v3', input=docs)` where len(docs) > 96.","commonSituations":"Bulk-embedding document stores, RAG ingestion pipelines, or migrating from providers with larger batch limits (OpenAI allows 2048+) without re-chunking. A single string input also becomes a 1-element list, so this only fires for genuinely large batches.","solutions":["Split your input into chunks of at most 96 texts and loop: `for batch in [input[i:i+96] for i in range(0, len(input), 96)]: ...`.","Use litellm's batching utilities or a task queue for very large corpora instead of one giant call.","Double-check you are not accidentally passing a list of characters (e.g. `list(text)`) which inflates the count."],"exampleFix":"# before\nresp = litellm.embedding(model=\"oci/generative-ai-cohere-embed-v3\", input=docs)  # len(docs) = 500\n\n# after\nembeddings = []\nfor i in range(0, len(docs), 96):\n    batch = docs[i:i+96]\n    resp = litellm.embedding(model=\"oci/generative-ai-cohere-embed-v3\", input=batch)\n    embeddings.extend(d[\"embedding\"] for d in resp.data)","handlingStrategy":"validation","validationCode":"OCI_BATCH = 96\nbatches = [input[i:i+OCI_BATCH] for i in range(0, len(input), OCI_BATCH)]\nassert all(len(b) <= OCI_BATCH for b in batches)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Chunk inputs to <=96 texts before calling oci/ embeddings","Wrap the loop in a helper so every call site is batch-safe","Log batch sizes during ingestion to catch accidental oversized calls"],"tags":["oci","embedding","batch-limit","input-validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}