Create a Specialized RAG Agent in Less than 5 Minutes
Contextual provides a platform for creating enterprise-grade AI agents, grounded in your documents and data. See a demo of our agents here.
Our APIs provide powerful — yet simple — interfaces for ingesting data, creating agents, and interacting with our state-of-the-art Contextual RAG 2.0 system.
Follow this guide to create your first agent! See https://github.com/ContextualAI/examples for easy-to-follow Jupyter notebooks for using our APIs.
Note: If you do not have access to the platform, you can create a workspace via the Start Free button in the upper right of the page. New workspaces are given a 30-day free trial of an agent and datastore.
Contextual uses API keys to authenticate requests. Only admins within a workspace can create API keys. To create a key:
Note that self-serve users are currently required to create agents and datastores through our UI. Otherwise, they will receive the following message: “This endpoint is disabled as you need to go through checkout. Please use the UI to make this request.”
A datastore contains all of the files that your agent(s) will be able to access. Each agent must be associated with at least one datastore. You can create a datastore using the /datastores
endpoint with the following command:
Remember to replace $API_KEY
with your key. You can rename the datastore if
you want.
If the request is successful, the id
of the newly created datastore will be returned to you. Be sure to save this id
as you will need it in subsequent steps!
Now that you’ve created a datastore, you can add documents to it. All documents are stored securely in the Contextual platform, and are processed in ways that we have optimized for RAG agents.
You can upload a single document using the following command:
Remember to:
{datastore_id}
in the url path with the datastore id from the previous step$API_KEY
with your API key{file_path}
with the path to the document on your machineIf the request is successful, the id
of the uploaded document will be returned to you. The time required to upload documents depends partly on their length and features. Some documents may require a few minutes to fully process after upload.
To check the status of documents uploaded into the datastore, use this command:
Remember to:
{datastore_id}
in the url path with the id
from the previous step$API_KEY
with your API keyYou should see the document you uploaded in the list, along with its ingestion_job_status
.
Now that you have a datastore with some files, you can use the /agents
endpoint to create your first agent.
Remember to:
$API_KEY
with your API keydatastore_ids
list field with the datastore id
from aboveIf the request is successful, the agent_id
of the newly created agent will be returned to you. You’ll need this to query your agent in the next step.
Now that you’ve set up an agent and uploaded documents for use with it to use, you can use the /query
endpoint to send messages:
Remember to:
{agent_id}
in the url path with the agent_id from the previous step$API_KEY
with your API keycontent
field with a question that is relevant to the document(s) you uploadedIf the request is successful, you’ll receive a response back that will contain:
Note: You can only query your agent once at least one document in the datastore has been processed. You can check the status of uploaded documents by following the instructions in the previous step.
🙌 Congratulations! You’ve now created a basic agent in the Contextual platform.
Now that you have a basic working agent, explore our advanced features:
Create a Specialized RAG Agent in Less than 5 Minutes
Contextual provides a platform for creating enterprise-grade AI agents, grounded in your documents and data. See a demo of our agents here.
Our APIs provide powerful — yet simple — interfaces for ingesting data, creating agents, and interacting with our state-of-the-art Contextual RAG 2.0 system.
Follow this guide to create your first agent! See https://github.com/ContextualAI/examples for easy-to-follow Jupyter notebooks for using our APIs.
Note: If you do not have access to the platform, you can create a workspace via the Start Free button in the upper right of the page. New workspaces are given a 30-day free trial of an agent and datastore.
Contextual uses API keys to authenticate requests. Only admins within a workspace can create API keys. To create a key:
Note that self-serve users are currently required to create agents and datastores through our UI. Otherwise, they will receive the following message: “This endpoint is disabled as you need to go through checkout. Please use the UI to make this request.”
A datastore contains all of the files that your agent(s) will be able to access. Each agent must be associated with at least one datastore. You can create a datastore using the /datastores
endpoint with the following command:
Remember to replace $API_KEY
with your key. You can rename the datastore if
you want.
If the request is successful, the id
of the newly created datastore will be returned to you. Be sure to save this id
as you will need it in subsequent steps!
Now that you’ve created a datastore, you can add documents to it. All documents are stored securely in the Contextual platform, and are processed in ways that we have optimized for RAG agents.
You can upload a single document using the following command:
Remember to:
{datastore_id}
in the url path with the datastore id from the previous step$API_KEY
with your API key{file_path}
with the path to the document on your machineIf the request is successful, the id
of the uploaded document will be returned to you. The time required to upload documents depends partly on their length and features. Some documents may require a few minutes to fully process after upload.
To check the status of documents uploaded into the datastore, use this command:
Remember to:
{datastore_id}
in the url path with the id
from the previous step$API_KEY
with your API keyYou should see the document you uploaded in the list, along with its ingestion_job_status
.
Now that you have a datastore with some files, you can use the /agents
endpoint to create your first agent.
Remember to:
$API_KEY
with your API keydatastore_ids
list field with the datastore id
from aboveIf the request is successful, the agent_id
of the newly created agent will be returned to you. You’ll need this to query your agent in the next step.
Now that you’ve set up an agent and uploaded documents for use with it to use, you can use the /query
endpoint to send messages:
Remember to:
{agent_id}
in the url path with the agent_id from the previous step$API_KEY
with your API keycontent
field with a question that is relevant to the document(s) you uploadedIf the request is successful, you’ll receive a response back that will contain:
Note: You can only query your agent once at least one document in the datastore has been processed. You can check the status of uploaded documents by following the instructions in the previous step.
🙌 Congratulations! You’ve now created a basic agent in the Contextual platform.
Now that you have a basic working agent, explore our advanced features: