Quickstart
You will create a workspace, connect a model, add one document, create an agent and run it. You need:
- a Camel Accounts login, and its access token from your app’s sign-in;
- a key for the Ngamia model gateway (
api.ngamia.cc); curlandjq.
export NGAMIA=https://api.ngamia.comSign up
Open api.ngamia.com/v1/auth/camel/start in a browser, sign in with Camel Accounts and create a workspace there, or do it with the API: exchange your Camel Accounts access token for a workspace and a platform token. Ngamia never stores the Camel token.
curl -s $NGAMIA/v1/auth/signup -H 'content-type: application/json' -d '{
"provider_token": "<camel access token>",
"workspace_name": "Duka la Asha"
}' | tee session.json
export NGAMIA_TOKEN=$(jq -r .access_token session.json)The token lasts expires_in seconds (a few minutes). Get a fresh one with
POST /v1/auth/token.
Connect a model
curl -s -X PATCH $NGAMIA/v1/workspace -H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' \
-d '{"model_api_key":"<your Ngamia gateway key>"}'The key is stored encrypted and never returned. GET /v1/workspace shows
"model_key_configured": true.
Add a document
curl -s $NGAMIA/v1/knowledge/documents -H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' -d '{
"source_id": "faq",
"external_id": "opening-hours",
"kind": "faq",
"title": "Saa za kazi / Opening hours",
"text": "Tuko wazi Jumatatu hadi Jumamosi, saa 2 asubuhi hadi saa 2 usiku. We are open Monday to Saturday, 8:00 to 20:00.",
"lang": "mixed"
}'Create an agent
curl -s $NGAMIA/v1/agents -H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' -d '{
"slug": "duka-helper",
"display_name": "Duka helper",
"instructions": "You help customers of Duka la Asha. Answer in the customer'"'"'s language. Use the shop knowledge for facts; if it does not say, offer to ask a person. Be brief.",
"knowledge": true
}'Run it
curl -s $NGAMIA/v1/agents/duka-helper/runs -H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' -d '{"input":"Mnafungua saa ngapi?"}' | jqCall it from your server
Create a key that can only run agents, and keep it on your server:
curl -s $NGAMIA/v1/api-keys -H "Authorization: Bearer $NGAMIA_TOKEN" \
-H 'content-type: application/json' -d '{"name":"website chat","scopes":["runs"]}'Then follow Call agents from your app.
Every step above is also available in the API reference, generated
from the same OpenAPI document the API serves at
https://api.ngamia.com/openapi.yaml.