The Analysis API is the intelligence layer of Surqo. Each analysis fuses 48 hours of sensor history with a 7-day weather forecast from Open-Meteo and crop-specific agronomic knowledge, then sends the combined context to Groq Llama 3.3 70B to generate actionable irrigation schedules, pest-risk assessments, and prioritised field recommendations. Once an analysis is saved you can continue the conversation with the AI agronomist — the SURQO persona — retaining full context of your farm’s data. The chat endpoint also supports image uploads for on-the-spot plant disease diagnosis.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ricardomb-tech/surqo/llms.txt
Use this file to discover all available pages before exploring further.
Trigger a farm analysis
POST /api/v1/analysis/analyze — Auth required — Rate limit: 10 requests / minute
When farm_id is provided, the API retrieves up to 500 sensor readings from the last 48 hours and builds trend context for the LLM. When alert_level in the response is "critical" and you supplied alert_email, a critical-alert email is dispatched automatically in the background.
Request body
Display name of the farm. Used in the generated report and any alert emails. Maximum 200 characters.
Farm latitude in decimal degrees (
-90 to 90). Used to fetch the Open-Meteo forecast.Farm longitude in decimal degrees (
-180 to 180). Used to fetch the Open-Meteo forecast.Crop type for analysis calibration. Accepted values:
maíz, yuca, plátano, café, arroz, algodón.UUID of the farm. When supplied, the API pulls 48 h of sensor history to enrich the LLM prompt with real field data and verifies the farm is owned by the authenticated user.
Email address to notify if the analysis produces a
critical alert. No email is sent for ok or warning levels.Response 201
Returns a full AnalysisResponse object.
Unique analysis identifier. Use this to retrieve the analysis later or to start a chat session.
Overall farm health status. One of
"ok", "warning", or "critical".Short headline describing the primary issue detected (e.g.
"Estrés hídrico moderado detectado").Normalised water stress index from
0.0 (no stress) to 1.0 (severe stress).Whether the model recommends irrigation within the forecast window.
ISO 8601 date string for the recommended next irrigation event.
Average air temperature (°C) derived from the 7-day forecast.
Total forecasted precipitation over the next 7 days in millimetres.
Average Vapour Pressure Deficit (kPa) from recent sensor readings.
Reference evapotranspiration (ET₀) for the next 7 days in millimetres.
Plain-language summary of the analysis results written for a non-technical audience.
LLM identifier used to generate the analysis (e.g.
"groq/llama-3.3-70b-versatile").Number of tokens in the prompt sent to the LLM.
Number of tokens in the LLM response.
Estimated cost in USD for this analysis call.
ISO 8601 timestamp of when the analysis was created.
Example
Response 201
Alert levels
| Level | Meaning |
|---|---|
ok | All monitored parameters are within healthy thresholds. No immediate action needed. |
warning | One or more parameters are approaching critical thresholds. Preventive action recommended. |
critical | Immediate intervention required. If alert_email was provided, a notification is dispatched. |
Error: quota exhausted
Response 402
Get analysis history
GET /api/v1/analysis/history/{farm_id} — Auth required
Returns the 10 most recent analyses for a farm, sorted newest first. The farm must belong to the authenticated user.
UUID of the farm whose analysis history to retrieve.
403 if the farm does not belong to the authenticated user.
Get a single analysis
GET /api/v1/analysis/{analysis_id} — Auth required
Returns the full AnalysisResponse for a specific analysis. Access is resolved by direct ownership (user_id); legacy analyses without a user_id are resolved through their linked farm.
UUID of the analysis to retrieve.
404 if the analysis does not exist or is not accessible by the authenticated user (the API intentionally returns 404 rather than 403 to avoid leaking record existence).
Chat with the AI agronomist
POST /api/v1/analysis/chat — Auth required — Rate limit: 20 requests / minute
Send a message to the SURQO AI agronomist. When analysis_id is provided, the full analysis context (crop type, alert level, stress indices, recommendations) is automatically injected into the LLM prompt. The chat also supports image uploads for plant disease diagnosis — the backend routes vision requests to Groq Llama 4 Scout or Anthropic Claude depending on configuration.
Messages are persisted per session_id. Omit session_id to start a new session; include it to continue an existing conversation.
Request body
The user’s message to the agronomist. Maximum 2000 characters.
UUID of a previously generated analysis. Injects that analysis’s farm data and recommendations as context for the LLM.
UUID of an existing chat session to continue. When omitted a new
session_id is generated and returned in the response.The last few turns of conversation to include as context. Each element is a
{role, content} object where role is "user" or "assistant". Recommended maximum: 10 messages.Base64-encoded image for visual plant disease diagnosis. When present the request is routed to a vision-capable model.
MIME type of the uploaded image. Defaults to
"image/jpeg". Common values: "image/jpeg", "image/png", "image/webp".Response 200
The agronomist’s reply text.
Session UUID. Pass this back in subsequent requests to maintain conversation continuity.
Number of prompt tokens consumed.
Number of completion tokens generated.
Text message example
Response 200
Image upload example (plant disease diagnosis)
Request body
List chat sessions for an analysis
GET /api/v1/analysis/{analysis_id}/chat-sessions — Auth required
Returns a summary list of all chat sessions initiated for a given analysis. Useful for building a sessions sidebar or continuing a previous conversation.
UUID of the analysis whose sessions to list.
Response 200
Returns an array of ChatSession objects.
Unique session identifier. Pass this as
session_id in POST /api/v1/analysis/chat to resume.Timestamp of the first message in the session.
Total number of user messages in the session.
The first 80 characters of the session’s opening user message.
Response 200
Get chat history for an analysis
GET /api/v1/analysis/{analysis_id}/chat-history — Auth required
Returns all persisted chat messages for an analysis in ascending chronological order, interleaving user and assistant turns. Optionally filter to a single session.
UUID of the analysis.
When provided, only messages belonging to that session are returned.
Response 200
Returns an array of ChatHistoryItem objects.
Unique message identifier.
Session this message belongs to.
Message author:
"user" or "assistant".Full message text.
ISO 8601 timestamp of when the message was persisted.
Response 200