{"record":{"id":"bf59d5ed440143b9","repo":"sigoden/aichat","slug":"the-client-doesn-t-support-embeddings-api","errorCode":null,"errorMessage":"The client doesn't support embeddings api","messagePattern":"The client doesn't support embeddings api","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client/common.rs","lineNumber":140,"sourceCode":"    async fn chat_completions_inner(\n        &self,\n        client: &ReqwestClient,\n        data: ChatCompletionsData,\n    ) -> Result<ChatCompletionsOutput>;\n\n    async fn chat_completions_streaming_inner(\n        &self,\n        client: &ReqwestClient,\n        handler: &mut SseHandler,\n        data: ChatCompletionsData,\n    ) -> Result<()>;\n\n    async fn embeddings_inner(\n        &self,\n        _client: &ReqwestClient,\n        _data: &EmbeddingsData,\n    ) -> Result<EmbeddingsOutput> {\n        bail!(\"The client doesn't support embeddings api\")\n    }\n\n    async fn rerank_inner(\n        &self,\n        _client: &ReqwestClient,\n        _data: &RerankData,\n    ) -> Result<RerankOutput> {\n        bail!(\"The client doesn't support rerank api\")\n    }\n\n    fn request_builder(\n        &self,\n        client: &reqwest::Client,\n        mut request_data: RequestData,\n    ) -> RequestBuilder {\n        self.patch_request_data(&mut request_data);\n        request_data.into_builder(client)\n    }","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/common.rs#L122-L158","documentation":"This is the default trait implementation of Client::embeddings_inner in src/client/common.rs. Clients that do not implement the embeddings API inherit this default, which unconditionally fails. Calling embeddings() on such a client therefore always errors — the provider simply has no embeddings capability wired up.","triggerScenarios":"Calling client.embeddings(data) (embeddings -> embeddings_inner) on any client that hasn't overridden embeddings_inner, e.g. the Bedrock, Claude, or Cohere clients.","commonSituations":"Generic code that calls embeddings on any Client without checking provider capability, switching a config to a provider that doesn't support embeddings, or copy-pasting embeddings code between providers.","solutions":["Use a client/provider that implements the embeddings API (e.g. OpenAI) for embedding workloads","Check the client's capability before calling embeddings and route to a supported provider","Contribute/implement embeddings_inner for the provider you need","Restructure the app so embedding generation is decoupled from chat provider choice"],"exampleFix":"// before\nlet embeddings = client.embeddings(data).await?;  // fails on Claude/Bedrock client\n// after\nlet embeddings = openai_client.embeddings(data).await?;","handlingStrategy":"fallback","validationCode":"// capability check before calling\nif !client.supports_embeddings() { /* route to OpenAI */ }","typeGuard":"fn supports_embeddings(client: &dyn Client) -> bool {\n    // only providers that override embeddings_inner\n    matches!(client.as_any().downcast_ref::<OpenAIClient>(), Some(_))\n}","tryCatchPattern":"match client.embeddings(data).await {\n    Err(e) if e.to_string().contains(\"doesn't support embeddings\") => {\n        openai_client.embeddings(data).await\n    }\n    r => r,\n}","preventionTips":["Document which providers implement embeddings_inner","Route embedding workloads to embedding-capable providers","Centralize provider capability checks in one config layer","Add a startup assertion when a workflow requires embeddings"],"tags":["embeddings","unsupported-feature","trait-default","capability"],"backgroundTag":"method-not-implemented","analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}