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/v1

Works 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.

POST/v1/chat/completions

Dispatch queries to the high-fidelity multimodal SautiFarm Agent. Supports streaming, speech translation context, vision disease inputs, and long-turn conversational history.

Request Body Parameters

ParameterTypeRequiredDescription
modelstringYes"sautifarm-agent" (or any designated string)
messagesarrayYesList of conversational {role, content} objects
streambooleanNoActivate Server-Sent Events (SSE) stream outputs
userstringNoA unique developer-defined identifier for your end-user

Messages Format Schema

RoleContentPurpose
systemstringConfigure custom behavior or inject specific agronomy constraints.
userstring | arrayThe farmer prompt. Array structure supports image URL payloads for multimodal disease recognition.
assistantstringPrevious 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);
GET/health

Retrieve current engine uptime metrics and microservice statuses. No authentication headers required.

Quick Start Checklist

  1. Create a free developer account on the Registration Page.
  2. Generate an active API Key on the Workspace API Keys Dashboard.
  3. Test and sandbox your integration on the Interactive API Playground.
  4. Modify your software's API clients to point to SautiFarm base engine endpoints.