{"record":{"id":"4e7c158d25c61df9","repo":"HKUDS/DeepTutor","slug":"openai-sdk-adapter-does-not-support-multimodal-co","errorCode":null,"errorMessage":"openai_sdk adapter does not support multimodal `contents`. Pick a multimodal-capable provider (cohere, aliyun).","messagePattern":"openai_sdk adapter does not support multimodal `contents`\\. Pick a multimodal-capable provider \\(cohere, aliyun\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/embedding/adapters/openai_sdk.py","lineNumber":62,"sourceCode":"    def _build_client(self) -> AsyncOpenAI:\n        # OpenRouter / custom gateways often don't validate the key, but the\n        # SDK refuses to construct without one. Use a placeholder when empty.\n        return AsyncOpenAI(\n            api_key=self.api_key or \"sk-no-key-required\",\n            base_url=self.base_url,\n            timeout=max(self.request_timeout, 60),\n            default_headers=(\n                {str(k): str(v) for k, v in self.extra_headers.items()}\n                if self.extra_headers\n                else None\n            ),\n            max_retries=2,\n            **openai_client_kwargs(timeout=max(self.request_timeout, 60)),\n        )\n\n    async def embed(self, request: EmbeddingRequest) -> EmbeddingResponse:\n        if request.contents:\n            raise ValueError(\n                \"openai_sdk adapter does not support multimodal `contents`. \"\n                \"Pick a multimodal-capable provider (cohere, aliyun).\"\n            )\n\n        model = request.model or self.model\n        kwargs: Dict[str, Any] = {\n            \"model\": model,\n            \"input\": request.texts,\n            # Unlike the gateway adapter (which omits `encoding_format` to avoid\n            # HTTP 400s), the official OpenAI/Azure API accepts it and callers\n            # expect float vectors, so pin \"float\" when none is set explicitly.\n            \"encoding_format\": request.encoding_format or \"float\",\n        }\n        dim_value = request.dimensions or self.dimensions\n        if dim_value and self._should_send_dimensions(model):\n            kwargs[\"dimensions\"] = dim_value\n\n        client = self._build_client()","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/embedding/adapters/openai_sdk.py#L44-L80","documentation":"The openai_sdk adapter (official OpenAI/Azure SDK path) is text-only by design; calling embed() with request.contents (multimodal/image inputs) is rejected up front with a pointer to multimodal-capable providers (cohere, aliyun).","triggerScenarios":"Any embed() call on the openai_sdk adapter where EmbeddingRequest.contents is truthy — e.g. image/document indexing configured against an OpenAI/Azure embedding binding.","commonSituations":"KB with image attachments wired to the default OpenAI text-embedding binding; config copied from a multimodal setup but adapter left as openai_sdk.","solutions":["Switch the embedding binding's provider/adapter to a multimodal-capable one (cohere, aliyun)","Or use openai_compatible adapter with a model name that looks multimodal (clip/vl markers)","Or drop contents and embed text only"],"exampleFix":"# before\nprovider = \"openai_sdk\"; model = \"text-embedding-3-small\"  # + contents -> raises\n# after\nprovider = \"cohere\"; model = \"embed-english-v3.0\"  # or aliyun multimodal embedding","handlingStrategy":"type-guard","validationCode":"if request.contents and adapter.provider == \"openai_sdk\":\n    raise ConfigurationError(\"switch to a multimodal-capable embedding provider (cohere/aliyun)\")","typeGuard":"def is_multimodal_adapter(adapter) -> bool:\n    return getattr(adapter, \"provider\", \"\") not in (\"openai_sdk\",)","tryCatchPattern":"try:\n    resp = await adapter.embed(req)\nexcept ValueError as e:\n    if \"multimodal\" in str(e):\n        adapter = get_multimodal_adapter()  # cohere / aliyun\n        resp = await adapter.embed(req)\n    else:\n        raise","preventionTips":["Document which embedding bindings are text-only","Gate image-indexing features on adapter multimodal capability checks"],"tags":["multimodal","embeddings","unsupported-operation","input-validation"],"backgroundTag":"model-does-not-support-input-modality","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}