Feature: v3/embeddings new page - #37
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
WalkthroughAdded a new V3 LLMs documentation page for embeddings (v3/llms/embeddings) with examples, schemas, guidance, and best practices; updated the docs navigation to include the new page. ChangesDocumentation Addition
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
v3/llms/embeddings.mdx (1)
119-126: ⚡ Quick winClarify/remove “smart routing” wording inside the embeddings worked example corpus.
In the worked example corpus (lines ~123-124), there’s a sentence about smart routing and
@edenai, but later (lines ~225-226) the page states smart routing is not supported on embeddings. To reduce confusion, tweak that corpus sentence to explicitly say smart routing applies to chat/completions (not embeddings), or remove that line from the corpus example.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v3/llms/embeddings.mdx` around lines 119 - 126, The corpus entry in the embeddings worked example (the array named corpus used with query) contains a misleading sentence about smart routing and `@edenai`; update that specific corpus element to either remove it or change its text to explicitly state that smart routing with `@edenai` applies to chat/completions (not embeddings). Locate the corpus array and replace the line "Smart routing picks an LLM automatically when you pass `@edenai` as the model." with a clarifying sentence such as "Smart routing with `@edenai` applies to chat/completions, not to embeddings." to avoid confusion. Ensure only that corpus element is changed and leave the rest of the corpus and the query variable intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@v3/llms/embeddings.mdx`:
- Around line 21-86: Vale is flagging “Deduplication” and “model_id” due to
hidden/look‑alike characters or smart quotes; open the MDX around those tokens
(the list item containing Deduplication and the code block that sets model_id),
remove any non‑ASCII or zero‑width characters, convert smart/curly quotes to
straight quotes, and retype the words so “Deduplication” uses a plain ASCII
D/e/d... sequence and the identifier model_id uses a normal underscore
character; then save and re-run the validator to confirm the warnings are gone.
- Around line 44-149: Update all placeholder auth tokens to match repo
guidelines: replace literal "YOUR_API_KEY" and "Authorization: Bearer
YOUR_API_KEY" with the approved placeholders (e.g., use Authorization: Bearer
<api_key> in curl and use variable names like api_token or sandbox_api_token for
Python examples). Locate and edit the headers and API key variables in examples
that define headers or API_KEY (references: headers, API_KEY, model_id, and the
curl -H lines) so they read the approved placeholder names and string form;
ensure Content-Type usage remains unchanged. Run a quick grep for "YOUR_API_KEY"
and "Authorization: Bearer" to catch all occurrences and apply the same rename
consistently across the snippets.
---
Nitpick comments:
In `@v3/llms/embeddings.mdx`:
- Around line 119-126: The corpus entry in the embeddings worked example (the
array named corpus used with query) contains a misleading sentence about smart
routing and `@edenai`; update that specific corpus element to either remove it
or change its text to explicitly state that smart routing with `@edenai` applies
to chat/completions (not embeddings). Locate the corpus array and replace the
line "Smart routing picks an LLM automatically when you pass `@edenai` as the
model." with a clarifying sentence such as "Smart routing with `@edenai` applies
to chat/completions, not to embeddings." to avoid confusion. Ensure only that
corpus element is changed and leave the rest of the corpus and the query
variable intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9b14c961-8ce2-44b9-8c2b-d9901b976426
📒 Files selected for processing (2)
docs.jsonv3/llms/embeddings.mdx
| - **Retrieval-Augmented Generation (RAG)** — embed your docs, retrieve the most relevant chunks for a user question, feed them into an LLM. | ||
| - **Semantic search** — match queries against documents by meaning, not keywords. | ||
| - **Recommendations** — suggest similar products, articles, or songs based on description vectors. | ||
| - **Clustering and topic discovery** — group thousands of texts by meaning without labels. | ||
| - **Deduplication** — find near-duplicates that don't share exact wording. | ||
| - **Anomaly detection** — flag inputs that look unlike anything in your corpus. | ||
| - **Classification** — train a small classifier on top of frozen embeddings instead of fine-tuning a full model. | ||
|
|
||
| ## Endpoints | ||
|
|
||
| ``` | ||
| GET /v3/embeddings/models List available embedding models | ||
| POST /v3/embeddings Create embeddings | ||
| ``` | ||
|
|
||
| Models are identified as `provider/model` — the same format used everywhere else in V3. | ||
|
|
||
| ## List available models | ||
|
|
||
| <CodeGroup> | ||
| ```python Python | ||
| import requests | ||
|
|
||
| response = requests.get( | ||
| "https://api.edenai.run/v3/embeddings/models", | ||
| headers={"Authorization": "Bearer YOUR_API_KEY"}, | ||
| ) | ||
|
|
||
| for model in response.json()["data"]: | ||
| print(model["id"], "-", model.get("context_length")) | ||
| ``` | ||
|
|
||
| ```bash cURL | ||
| curl https://api.edenai.run/v3/embeddings/models \ | ||
| -H "Authorization: Bearer YOUR_API_KEY" | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| Each item exposes `id`, `owned_by`, `context_length`, `pricing`, `capabilities`, and `regions`. Use any `id` as the `model` field below. | ||
|
|
||
| ## Create embeddings | ||
|
|
||
| The example picks a model from the catalog at runtime so the snippet never goes stale. | ||
|
|
||
| <CodeGroup> | ||
| ```python Python | ||
| import requests | ||
|
|
||
| headers = {"Authorization": "Bearer YOUR_API_KEY"} | ||
|
|
||
| model_id = requests.get( | ||
| "https://api.edenai.run/v3/embeddings/models", | ||
| headers=headers, | ||
| ).json()["data"][0]["id"] | ||
|
|
||
| response = requests.post( | ||
| "https://api.edenai.run/v3/embeddings", | ||
| headers={**headers, "Content-Type": "application/json"}, | ||
| json={ | ||
| "model": model_id, | ||
| "input": "The quick brown fox jumps over the lazy dog", | ||
| }, | ||
| ).json() | ||
|
|
||
| vector = response["data"][0]["embedding"] | ||
| print(f"{model_id}: {len(vector)} dimensions, cost=${response['cost']}") |
There was a problem hiding this comment.
Fix vale-spellcheck warnings to avoid doc validation failures.
Vale spellcheck is warning about:
- Line ~25: “Deduplication”
- Line ~71: “model_id”
Even though the excerpt looks correct, the validation tool is still flagging them—so please re-check the source MDX around those lines (look for hidden Unicode, smart quotes, or look-alike characters) and update wording/identifiers until the warnings disappear.
🧰 Tools
🪛 Betterleaks (1.1.2)
[high] 54-55: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.
(curl-auth-header)
🪛 GitHub Check: Mintlify Validation (edenai) - vale-spellcheck
[warning] 25-25: v3/llms/embeddings.mdx#L25
Did you really mean 'Deduplication'?
[warning] 71-71: v3/llms/embeddings.mdx#L71
Did you really mean 'model_id'?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@v3/llms/embeddings.mdx` around lines 21 - 86, Vale is flagging
“Deduplication” and “model_id” due to hidden/look‑alike characters or smart
quotes; open the MDX around those tokens (the list item containing Deduplication
and the code block that sets model_id), remove any non‑ASCII or zero‑width
characters, convert smart/curly quotes to straight quotes, and retype the words
so “Deduplication” uses a plain ASCII D/e/d... sequence and the identifier
model_id uses a normal underscore character; then save and re-run the validator
to confirm the warnings are gone.
| response = requests.get( | ||
| "https://api.edenai.run/v3/embeddings/models", | ||
| headers={"Authorization": "Bearer YOUR_API_KEY"}, | ||
| ) | ||
|
|
||
| for model in response.json()["data"]: | ||
| print(model["id"], "-", model.get("context_length")) | ||
| ``` | ||
|
|
||
| ```bash cURL | ||
| curl https://api.edenai.run/v3/embeddings/models \ | ||
| -H "Authorization: Bearer YOUR_API_KEY" | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| Each item exposes `id`, `owned_by`, `context_length`, `pricing`, `capabilities`, and `regions`. Use any `id` as the `model` field below. | ||
|
|
||
| ## Create embeddings | ||
|
|
||
| The example picks a model from the catalog at runtime so the snippet never goes stale. | ||
|
|
||
| <CodeGroup> | ||
| ```python Python | ||
| import requests | ||
|
|
||
| headers = {"Authorization": "Bearer YOUR_API_KEY"} | ||
|
|
||
| model_id = requests.get( | ||
| "https://api.edenai.run/v3/embeddings/models", | ||
| headers=headers, | ||
| ).json()["data"][0]["id"] | ||
|
|
||
| response = requests.post( | ||
| "https://api.edenai.run/v3/embeddings", | ||
| headers={**headers, "Content-Type": "application/json"}, | ||
| json={ | ||
| "model": model_id, | ||
| "input": "The quick brown fox jumps over the lazy dog", | ||
| }, | ||
| ).json() | ||
|
|
||
| vector = response["data"][0]["embedding"] | ||
| print(f"{model_id}: {len(vector)} dimensions, cost=${response['cost']}") | ||
| ``` | ||
|
|
||
| ```bash cURL | ||
| # Replace MODEL_ID with any id returned by GET /v3/embeddings/models | ||
| curl https://api.edenai.run/v3/embeddings \ | ||
| -H "Authorization: Bearer YOUR_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "MODEL_ID", | ||
| "input": "The quick brown fox jumps over the lazy dog" | ||
| }' | ||
| ``` | ||
| </CodeGroup> | ||
|
|
||
| ## Worked example: semantic search | ||
|
|
||
| This is the smallest end-to-end example that demonstrates the full retrieval pattern: embed a query and a small corpus in **one batched call**, score with cosine similarity, return the top matches. | ||
|
|
||
| ```python Python | ||
| import requests | ||
| import numpy as np | ||
|
|
||
| API_KEY = "YOUR_API_KEY" | ||
| headers = {"Authorization": f"Bearer {API_KEY}"} | ||
|
|
||
| # 1. Pick a model from the catalog. | ||
| model_id = requests.get( | ||
| "https://api.edenai.run/v3/embeddings/models", | ||
| headers=headers, | ||
| ).json()["data"][0]["id"] | ||
|
|
||
| # 2. Define a query and a corpus of documents to search over. | ||
| query = "How do I track my API costs?" | ||
| corpus = [ | ||
| "Eden AI returns a `cost` field on every response so you can track spend per call.", | ||
| "You can set a monthly budget cap from the dashboard under Plans & Pricing.", | ||
| "Smart routing picks an LLM automatically when you pass `@edenai` as the model.", | ||
| "The /v3/models endpoint lists every available chat-completions model.", | ||
| "To upload files for vision-capable LLMs, use the /v3/upload endpoint.", | ||
| ] | ||
|
|
||
| # 3. Embed query + corpus in a single batched call. Eden returns vectors in input order. | ||
| payload = {"model": model_id, "input": [query, *corpus]} | ||
| response = requests.post( | ||
| "https://api.edenai.run/v3/embeddings", | ||
| headers={**headers, "Content-Type": "application/json"}, | ||
| json=payload, | ||
| ).json() | ||
|
|
||
| vectors = np.array([item["embedding"] for item in response["data"]]) | ||
| query_vec, corpus_vecs = vectors[0], vectors[1:] | ||
|
|
||
| # 4. Cosine similarity = dot product of L2-normalized vectors. | ||
| def normalize(v): | ||
| return v / np.linalg.norm(v, axis=-1, keepdims=True) | ||
|
|
||
| scores = normalize(corpus_vecs) @ normalize(query_vec) | ||
| ranking = np.argsort(scores)[::-1] | ||
|
|
||
| print(f"Embedded {len(corpus) + 1} texts for ${response['cost']:.6f}\n") | ||
| for rank, idx in enumerate(ranking[:3], start=1): | ||
| print(f"{rank}. ({scores[idx]:.3f}) {corpus[idx]}") | ||
| ``` |
There was a problem hiding this comment.
Fix auth header/token placeholders to match docs guidelines (and avoid secret scanners).
The MDX examples currently use Authorization: Bearer YOUR_API_KEY and an API_KEY variable, but the repo guidance says to use Authorization: Bearer <api_key> and api_token / sandbox_api_token in examples. This is also what triggered the Betterleaks findings for the curl headers (see lines ~54-55 and ~91-92).
✅ Suggested change (apply across the code snippets)
-headers={"Authorization": "Bearer YOUR_API_KEY"},
+headers={"Authorization": "Bearer <api_key>"},
- -H "Authorization: Bearer YOUR_API_KEY"
+ -H "Authorization: Bearer <api_key>"
-headers = {"Authorization": "Bearer YOUR_API_KEY"}
+api_token = "YOUR_API_TOKEN"
+headers = {"Authorization": f"Bearer {api_token}"}
- -H "Authorization: Bearer YOUR_API_KEY" \
+ -H "Authorization: Bearer <api_key>" \For the worked example, rename:
-API_KEY = "YOUR_API_KEY"
-headers = {"Authorization": f"Bearer {API_KEY}"}
+api_token = "YOUR_API_TOKEN"
+headers = {"Authorization": f"Bearer {api_token}"}This should satisfy the coding guidelines and reduce the chance of security-scanner failures on placeholders.
🧰 Tools
🪛 Betterleaks (1.1.2)
[high] 54-55: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.
(curl-auth-header)
[high] 91-92: Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.
(curl-auth-header)
🪛 GitHub Check: Mintlify Validation (edenai) - vale-spellcheck
[warning] 71-71: v3/llms/embeddings.mdx#L71
Did you really mean 'model_id'?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@v3/llms/embeddings.mdx` around lines 44 - 149, Update all placeholder auth
tokens to match repo guidelines: replace literal "YOUR_API_KEY" and
"Authorization: Bearer YOUR_API_KEY" with the approved placeholders (e.g., use
Authorization: Bearer <api_key> in curl and use variable names like api_token or
sandbox_api_token for Python examples). Locate and edit the headers and API key
variables in examples that define headers or API_KEY (references: headers,
API_KEY, model_id, and the curl -H lines) so they read the approved placeholder
names and string form; ensure Content-Type usage remains unchanged. Run a quick
grep for "YOUR_API_KEY" and "Authorization: Bearer" to catch all occurrences and
apply the same rename consistently across the snippets.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
v3/llms/embeddings.mdx (1)
46-47:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse the approved auth placeholder and token variable names consistently.
The examples still use
YOUR_API_KEY/API_KEYandBearer YOUR_API_KEY. Please switch to the documented convention (Authorization: Bearer <api_key>, andapi_tokenorsandbox_api_tokenin code) to align with docs policy and avoid secret-scanner noise.Suggested patch
-response = requests.get( - "https://api.edenai.run/v3/embeddings/models", - headers={"Authorization": "Bearer YOUR_API_KEY"}, -) +response = requests.get( + "https://api.edenai.run/v3/embeddings/models", + headers={"Authorization": "Bearer <api_key>"}, +) @@ -curl https://api.edenai.run/v3/embeddings/models \ - -H "Authorization: Bearer YOUR_API_KEY" +curl https://api.edenai.run/v3/embeddings/models \ + -H "Authorization: Bearer <api_key>" @@ -headers = {"Authorization": "Bearer YOUR_API_KEY"} +api_token = "YOUR_API_TOKEN" +headers = {"Authorization": f"Bearer {api_token}"} @@ -curl https://api.edenai.run/v3/embeddings \ - -H "Authorization: Bearer YOUR_API_KEY" \ +curl https://api.edenai.run/v3/embeddings \ + -H "Authorization: Bearer <api_key>" \ -H "Content-Type: application/json" \ @@ -API_KEY = "YOUR_API_KEY" -headers = {"Authorization": f"Bearer {API_KEY}"} +api_token = "YOUR_API_TOKEN" +headers = {"Authorization": f"Bearer {api_token}"}As per coding guidelines, "Use
Authorization: Bearer <api_key>header format for API authentication in code examples" and "Distinguish token types in code examples:api_tokenfor production andsandbox_api_tokenfor testing (no real provider calls)".Also applies to: 54-56, 69-70, 91-93, 109-111
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@v3/llms/embeddings.mdx` around lines 46 - 47, Replace all occurrences of the literal placeholders "YOUR_API_KEY" / "API_KEY" and the header value "Bearer YOUR_API_KEY" with the approved conventions: use the header "Authorization: Bearer <api_key>" and in code examples use the variable names api_token for production examples or sandbox_api_token for test/sandbox examples; specifically update the header object that currently reads "Authorization": "Bearer YOUR_API_KEY" and any variables named API_KEY to api_token or sandbox_api_token so examples follow the documented auth placeholder convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@v3/llms/embeddings.mdx`:
- Around line 46-47: Replace all occurrences of the literal placeholders
"YOUR_API_KEY" / "API_KEY" and the header value "Bearer YOUR_API_KEY" with the
approved conventions: use the header "Authorization: Bearer <api_key>" and in
code examples use the variable names api_token for production examples or
sandbox_api_token for test/sandbox examples; specifically update the header
object that currently reads "Authorization": "Bearer YOUR_API_KEY" and any
variables named API_KEY to api_token or sandbox_api_token so examples follow the
documented auth placeholder convention.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c48202ce-486e-4cd1-9e8b-899615367109
📒 Files selected for processing (2)
docs.jsonv3/llms/embeddings.mdx
✅ Files skipped from review due to trivial changes (1)
- docs.json
I did a page with a good SEO aspect might be a bit different from the responses and chat completion, I will add some content on them to on the next PR
Summary by CodeRabbit