API Documentation Reference
Build agricultural applications with SautiFarm AI models using standardized OpenAI-compatible SDKs or raw HTTPS clients.
Base Engine Endpoint
All API requests must be routed to your SautiFarm engine instance. It functions as a complete drop-in replacement for OpenAI endpoints.
https://engine.sautifarm.com/v1Works out of the box with any official OpenAI SDK. Simply modify the base_url parameter.
API Token Authentication
Requests must authenticate by passing your SautiFarm API key in the custom X-API-Key request header.
Generate and manage workspace keys on the API Keys Dashboard Page.
/v1/chat/completionsDispatch queries to the high-fidelity multimodal SautiFarm Agent. Supports streaming, speech translation context, vision disease inputs, and long-turn conversational history.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | "sautifarm-agent" (or any designated string) |
| messages | array | Yes | List of conversational {role, content} objects |
| stream | boolean | No | Activate Server-Sent Events (SSE) stream outputs |
| user | string | No | A unique developer-defined identifier for your end-user |
Messages Format Schema
| Role | Content | Purpose |
|---|---|---|
| system | string | Configure custom behavior or inject specific agronomy constraints. |
| user | string | array | The farmer prompt. Array structure supports image URL payloads for multimodal disease recognition. |
| assistant | string | Previous model response content to build multi-turn conversational memory. |
Sample Requests
1. Standard Shell Request (cURL)
curl -X POST https://engine.sautifarm.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: sf_your_key_here" \
-d '{
"model": "sautifarm-agent",
"messages": [
{"role": "user", "content": "When should I plant maize in Kenya?"}
]
}'2. Visual Multimodal Analysis (Disease Identification)
curl -X POST https://engine.sautifarm.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: sf_your_key_here" \
-d '{
"model": "sautifarm-agent",
"messages": [
{"role": "user", "content": [
{"type": "text", "text": "What disease is affecting this leaf?"},
{"type": "image_url", "image_url": {"url": "https://example.com/leaf_photo.jpg"}}
]}
]
}'3. Python Integration (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://engine.sautifarm.com/v1",
api_key="sf_your_key_here"
)
response = client.chat.completions.create(
model="sautifarm-agent",
messages=[{"role": "user", "content": "What is the market price of maize in Eldoret?"}]
)
print(response.choices[0].message.content)4. Node.js Integration (Standard Fetch API)
const response = await fetch("https://engine.sautifarm.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "sf_your_key_here"
},
body: JSON.stringify({
model: "sautifarm-agent",
messages: [{ role: "user", content: "Mambo! Hali gani?" }]
})
});
const data = await response.json();
console.log(data.choices[0].message.content);/healthRetrieve current engine uptime metrics and microservice statuses. No authentication headers required.
Quick Start Checklist
- Create a free developer account on the Registration Page.
- Generate an active API Key on the Workspace API Keys Dashboard.
- Test and sandbox your integration on the Interactive API Playground.
- Modify your software's API clients to point to SautiFarm base engine endpoints.