Skip to content

Conversation

@tomek-labuk
Copy link
Contributor

@tomek-labuk tomek-labuk commented Dec 1, 2025

Description

Fixes #3351

Preview Links

https://deploy-preview-3594--kongdeveloper.netlify.app/plugins/ai-rag-injector/#access-control-and-metadata-filtering
https://deploy-preview-3594--kongdeveloper.netlify.app//how-to/use-ai-rag-injector-acls/
https://deploy-preview-3594--kongdeveloper.netlify.app//how-to/filter-knowledge-based-queries-with-rag-injector/

Checklist

  • Tested how-to docs. If not, note why here.
  • All pages contain metadata.
  • Any new docs link to existing docs.
  • All autogenerated instructions render correctly (API, decK, Konnect, Kong Manager).
  • Style guide (capitalized gateway entities, placeholder URLs) implemented correctly.
  • Every page has a description entry in frontmatter.
  • Add new pages to the product documentation index (if applicable).

@netlify
Copy link

netlify bot commented Dec 1, 2025

Deploy Preview for kongdeveloper ready!

Name Link
🔨 Latest commit c529ceb
🔍 Latest deploy log https://app.netlify.com/projects/kongdeveloper/deploys/6937b69ed4cbf200086ef4af
😎 Deploy Preview https://deploy-preview-3594--kongdeveloper.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tomek-labuk tomek-labuk changed the base branch from main to release/gateway-3.13 December 1, 2025 12:49
@tomek-labuk tomek-labuk marked this pull request as ready for review December 2, 2025 09:01
@tomek-labuk tomek-labuk requested a review from a team as a code owner December 2, 2025 09:01
Copy link

@xiaocang xiaocang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this document is clear

@xiaocang
Copy link

xiaocang commented Dec 3, 2025

There’s a discussion about the request body structure, and perhaps the request body structure may need to be adjusted as well. https://github.com/Kong/kong-ee/pull/15327

@xiaocang
Copy link

xiaocang commented Dec 3, 2025

According to the OpenAI SDK behavior when users call:

  client.chat.completions.create(
      model="gpt-4",
      messages=[...],
      extra_body={"ai-rag-injector": {...}}
  )

The SDK merges extra_body contents at the root level of the HTTP request body. Kong actually receives:

  {
    "model": "gpt-4",
    "messages": [...],
    "ai-rag-injector": {...}
  }

NOT nested under an extra_body key.

so, let's request without extra_body wrapper in the doc, after this PR https://github.com/Kong/kong-ee/pull/15348 merged

@tomek-labuk
Copy link
Contributor Author

According to the OpenAI SDK behavior when users call:

  client.chat.completions.create(
      model="gpt-4",
      messages=[...],
      extra_body={"ai-rag-injector": {...}}
  )

The SDK merges extra_body contents at the root level of the HTTP request body. Kong actually receives:

  {
    "model": "gpt-4",
    "messages": [...],
    "ai-rag-injector": {...}
  }

NOT nested under an extra_body key.

so, let's request without extra_body wrapper in the doc, after this PR Kong/kong-ee#15348 merged

According to the OpenAI SDK behavior when users call:

  client.chat.completions.create(
      model="gpt-4",
      messages=[...],
      extra_body={"ai-rag-injector": {...}}
  )

The SDK merges extra_body contents at the root level of the HTTP request body. Kong actually receives:

  {
    "model": "gpt-4",
    "messages": [...],
    "ai-rag-injector": {...}
  }

NOT nested under an extra_body key.

so, let's request without extra_body wrapper in the doc, after this PR Kong/kong-ee#15348 merged

@xiaocang - I've updated both the how-to and the main overview. Also, I've tested with a dev image from your PR and it does work without the extra_body param.

@Guaris Guaris self-assigned this Dec 8, 2025
Copy link
Contributor

@Guaris Guaris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good and detailed PR.

{:.info}
> If your Redis instance runs in a separate Docker container from Kong, use `host.docker.internal` for `vectordb.redis.host`.
## Ingest content with metadata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to ingest everything as one step, then we can tell the user what was ingested. Having so many ingestion steps made sense in the validation step but actually copy and pasting them in didn't add anything to my understanding of the doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try a python script. The thing is that when I tried it in the first place, the collections were not ingested properly which messed up everything

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, I've included python scripts for ingesting both collections :) – tested and it works as expected

Comment on lines 250 to 281
{:.info}
> GCP Memorystore Redis clusters do not support the AI RAG Injector plugin. The Redis JSON module required for vector operations is not available in GCP's managed Redis service.
>
> Attempting to ingest chunks with GCP Redis results in the following error:
>
> ```json
> {"message":"Failed to load the 'redis' vector database driver: failed to initialize vector database strategy: failed to create index: JSON module is not loaded."}
>```
{% include_cached /plugins/ai-vector-db.md name=page.name %}
## Access control and metadata filtering {% new_in 3.13 %}
Once you've configured your vector database and ingested content, you can control which [Consumers](/gateway/entities/consumer/) access specific knowledge base articles and refine query results using metadata filters.
### Collections
A collection is a logical grouping of knowledge base articles with independent access control rules. When you ingest content via the Admin API, assign it to a collection using the `collection` field in the metadata.
Example metadata structure:
```json
{
"content": "Quarterly revenue increased 15%...",
"metadata": {
"collection": "finance-reports",
"date": "2023-10-14",
"tags": ["finance", "quarterly"],
"source": "internal"
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth adding this to an FAQ instead of at the top of this section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done!

tomek-labuk and others added 3 commits December 9, 2025 05:50
Co-authored-by: Angel <Guaris@users.noreply.github.com>
@tomek-labuk tomek-labuk requested a review from Guaris December 9, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants