Knowledge
Give your Human Agent your organization's documents to answer from, in its prompt or by searching them during a conversation.
Knowledge is the text and documents your agents answer from: product guides, policies, price lists, FAQs. It belongs to your organization, is grouped into collections, and each agent uses only the collections you tick for it.
Adding knowledge
Open Knowledge in the Ojin dashboard sidebar and choose Add knowledge. You can:
Upload files:
.txt,.md,.pdf,.docx(Word) or.pptx(PowerPoint), several at once.Paste text: give it a title and paste the text.
Every item goes into a collection. Pick an existing one, or name a new one in the same dialog.
An item can't be edited. To change one, delete it and add the new version.
Status
Each item shows its status on the Knowledge page:
Processing…: Ojin is extracting the text of a document, or making an item searchable.
Ready: agents can use the item the way its collection says.
Failed: the item can't be used, with the reason. Some failures offer Retry. Others mean the file needs fixing, such as "This file can't be read" for a password-protected or damaged file.
Try a search on the Knowledge page shows what a search finds in your organization's knowledge.
Collections
Every item belongs to exactly one collection, and each collection is one of two kinds:
Search only (the default for a new collection): the agent searches the collection during a conversation and gets the passages that best match.
Always in the prompt: the full text of the collection's items goes into the agent's prompt at the start of every session.
Use Always in the prompt for short material the agent needs in nearly every conversation, such as opening hours or key policies. Use Search only for everything else, especially long documents.
Collection names are unique within your organization, ignoring case.
Switching a collection between the two kinds applies from each agent's next session.
Moving an item into a Search only collection makes it Processing… until it can be searched there. An item moved into an Always in the prompt collection keeps its status.
Deleting a collection deletes every item in it, and removes it from every agent that uses it.
Using knowledge in an agent
In an Ojin Agent's settings, on the Basics tab under Conversation, tick the collections the agent uses under Knowledge. An agent with nothing ticked uses no knowledge. An agent can use up to 45 collections. Changes apply from the agent's next session.
Under the checklist, the dashboard estimates how much the ticked Always in the prompt collections add to the agent's prompt ("Adds ≈N tokens…").
How the agent uses it
Always in the prompt: the ready items of the agent's ticked Always in the prompt collections are added after your system prompt, under a "Reference material" heading, and are sent to the LLM with every reply.
Search only: when a ticked Search only collection has a ready item, the agent gets a built-in
search_knowledgetool. It searches only the collections ticked for it, of both kinds, and gets 5 passages per search, each with its item's title and, for PDF and Word files, its page.The agent may search up to 3 times per caller turn, and searches count toward the 3 tool calls per model response.
search_knowledgeis reserved: a custom tool of that name is replaced by the built-in search while the agent has searchable knowledge.The agent is asked to say a short line before it searches, such as that it's looking it up. On the default model it doesn't, in our measurements, so callers hear a short pause before the answer.
When nothing matches, or a search fails, the agent hears that nothing in your knowledge matched.
Text you add to an Always in the prompt collection is ready for the agent's prompt at once, but searches find it only after Ojin has indexed it, usually within minutes. Nothing on the Knowledge page shows that step. Material you want found by search belongs in a Search only collection, where Ready means searchable.
Ojin tells the agent to answer from your reference material when it covers the question. It adds no instruction to cite sources, to say when your knowledge doesn't cover something, or to keep the material private. Put any such rules in the agent's system prompt.
Limits
A text item (.txt, .md or pasted text)
4 MiB
A document (.pdf, .docx, .pptx)
500 MB, and up to 4 MiB of extracted text
Item title
200 characters
Collection name
100 characters
Collections per agent
45
Always in the prompt knowledge one session loads
4 MiB of text and 500 items
When an agent's ticked Always in the prompt collections hold more than the session limit, the agent's sessions don't start: connecting answers 422 (see the Session API's error responses). The Knowledge page and the agent's checklist warn when that happens. Untick a collection or switch it to Search only.
The agent's model sets a lower practical limit. The default model reads about 128,000 tokens in all: your system prompt, the knowledge in the prompt, and the conversation so far. Keep the "Adds ≈N tokens" figure well below that, and move larger material to Search only collections. Above the model's limit the agent stays silent: the call stays connected, but the agent can't reply. The estimate assumes about 4 bytes of text per token, so it undercounts text in scripts such as Japanese or Arabic.
Managing knowledge with the API
Every knowledge endpoint accepts your API key in the X-API-Key header (see Get your API key) and acts on that key's organization. The base URL is https://api.ojin.ai.
GET /v1/knowledge/collections
List the organization's collections, by name
POST /v1/knowledge/collections
Create a collection: name, and in_prompt (false for Search only, the default)
PATCH /v1/knowledge/collections/{collection_id}
Rename a collection (name) or switch its kind (in_prompt)
DELETE /v1/knowledge/collections/{collection_id}
Delete a collection and every item in it
POST /v1/knowledge/uploads
Start an upload (see below)
POST /v1/knowledge/items
Finish an upload (see below)
GET /v1/knowledge/items
List every item, without its text, plus the organization's limits
GET /v1/knowledge/items/{item_id}
One item, with the text agents load as content
PATCH /v1/knowledge/items/{item_id}
Move an item to another collection (collection_id)
DELETE /v1/knowledge/items/{item_id}
Delete an item
POST /v1/knowledge/items/{item_id}/retry
Retry an item whose retryable is true
POST /v1/knowledge/search
Search the organization's knowledge (see below)
Uploading a file
Create a collection first: every item needs one.
Start the upload with the file's exact size in bytes and its type:
The answer holds an
item_id, anupload_url, theupload_headersthe upload must send, andexpires_at. A file over the limit for its type answers413.Upload the file to
upload_urlwith aPUTthat sends exactly theupload_headersand nothing else, within 15 minutes:Upload from your server. The upload URL accepts browser uploads only from the Ojin dashboard.
Finish the upload with the same
item_idandfile_extension, atitle, and thecollection_idit goes in:A new item answers
201; finishing the same upload again returns the item with200. A collection that isn't your organization's answers400.
Each item carries a status (processing, ready or failed). A failed item also has a failure_reason:
failure_reason
Meaning
no_text
No text was found in the file
too_much_text
The file has more text than an agent can load
unsupported
The file can't be read; check it isn't password-protected or damaged
source_missing
The uploaded file is missing; delete the item and upload it again
processing_failed
The file couldn't be processed; retry it when retryable is true
not_searchable
An item in a Search only collection couldn't be made searchable; retry it when retryable is true
Choosing an agent's collections
Set the collections an agent uses with knowledge_collection_ids on PATCH /v1/agents/{agent_id}:
The list holds ids of your organization's collections, at most 45, with no id twice. An id that isn't your organization's answers
400.It replaces the agent's whole list. An empty list means the agent uses no knowledge.
Leave the field out to keep the list as it is.
Reading the agent returns its current
knowledge_collection_ids.
Searching from your own LLM
If you run your own LLM, for example when you drive a face model through the Python SDK or the realtime API, you can search your organization's knowledge and put the passages into your LLM's prompt before it answers.
queryis 1 to 1,000 characters.max_resultsis 1 to 20, and 5 when left out.Results come most relevant first.
pageis set for PDF and Word files, andnullotherwise.scoreis a relevance score: higher is more relevant.A search covers every collection of the organization, of both kinds. An item in a Search only collection is searchable once it shows Ready. Text in an Always in the prompt collection becomes searchable a little later, usually within minutes, with no status showing it. So keep the material your pipeline searches in Search only collections.
No results is an empty
resultslist, not an error.Searches are limited to about 60 a minute per organization, counting the dashboard's Try a search but not your agents' own searches. Past the limit, a search can answer
429: wait and try again.A search usually takes about a second.
Last updated
Was this helpful?