{"record":{"id":"5c83682d9f4b80a8","repo":"BerriAI/litellm","slug":"oci-embedtext-does-not-support-token-array-inputs","errorCode":null,"errorMessage":"OCI embedText does not support token-array inputs. Convert token lists to strings before calling embedding().","messagePattern":"OCI embedText does not support token-array inputs\\. Convert token lists to strings before calling embedding\\(\\)\\.","errorType":"exception","errorClass":"OCIError","httpStatus":400,"severity":"error","filePath":"litellm/llms/oci/embed/transformation.py","lineNumber":200,"sourceCode":"        creds: Final = resolve_oci_credentials(optional_params)\n        compartment_id: Final = creds[\"oci_compartment_id\"]\n        if not compartment_id:\n            raise OCIError(\n                status_code=400,\n                message=(\n                    \"oci_compartment_id is required for OCI embedding requests. \"\n                    \"Pass it as optional_params or set the OCI_COMPARTMENT_ID env var.\"\n                ),\n            )\n\n        # Normalise input to a flat list of strings\n        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            )","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/embed/transformation.py#L182-L218","documentation":"LiteLLM's OCI generative-ai embedding adapter normalizes the `input` argument into a flat list of strings before building the OCI embedText request. The OCI embedText API only accepts plain strings, not token arrays (lists of ints) like some OpenAI-compatible endpoints do. If any element of `input` is itself a list, this 400 error is raised during request transformation, before any HTTP call.","triggerScenarios":"Calling `litellm.embedding(model='oci/generative-ai-cohere-embed-v3', input=[[101, 102, 103], [104, 105]])` or passing tokenized text produced by a tokenizer (e.g. tiktoken output) as the input list. Any nested list inside the input list triggers it immediately in transform_embedding_request.","commonSituations":"Porting code from providers that accept token IDs (OpenAI legacy `embedding(input=[tokens])` usage), or piping tokenizer output directly into litellm.embedding. Also happens when a caller assumed litellm would transparently detokenize.","solutions":["Convert token lists to strings before calling embedding(): decode with your tokenizer, e.g. `input=[tokenizer.decode(t) for t in token_lists]`.","If you only have token arrays, embed them with a provider that supports them, or restructure your pipeline to keep raw text until the embedding call.","Verify each item with `assert all(isinstance(x, str) for x in input)` before the call to fail fast on your side."],"exampleFix":"# before\nresp = litellm.embedding(model=\"oci/generative-ai-cohere-embed-v3\", input=[[101, 102, 103]])\n\n# after\nresp = litellm.embedding(model=\"oci/generative-ai-cohere-embed-v3\", input=[\"hello world\"])","handlingStrategy":"validation","validationCode":"def is_flat_str_list(input) -> bool:\n    if isinstance(input, str):\n        return True\n    return isinstance(input, list) and all(isinstance(x, str) for x in input)\n\nif not is_flat_str_list(input):\n    input = [tokenizer.decode(t) if isinstance(t, list) else str(t) for t in input]","typeGuard":"def is_oci_embed_input_valid(input) -> bool:\n    \"\"\"True when input is a string or flat list of strings (no nested token arrays).\"\"\"\n    if isinstance(input, str):\n        return True\n    return isinstance(input, list) and all(isinstance(i, str) for i in input)","tryCatchPattern":"try:\n    resp = litellm.embedding(model=\"oci/...\", input=input)\nexcept litellm.llms.oci.OCIError as e:\n    if \"token-array\" in str(e):\n        input = [\" \".join(map(str, t)) if isinstance(t, list) else t for t in input]\n        resp = litellm.embedding(model=\"oci/...\", input=input)\n    else:\n        raise","preventionTips":["Never pass raw tokenizer output to oci/ embedding models","Keep a helper that asserts flat string lists before any embedding call","Document in your pipeline that OCI embedText is string-only"],"tags":["oci","embedding","input-validation","tokens"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}