Skip to main content
Shelfforce is designed for machine-to-machine integration. Whether you are building an AI agent with Claude, GPT, or an open-source model, Shelfforce provides everything needed for automatic tool discovery, reliable execution, and event-driven workflows.

Discovery

AI agents need to understand what tools are available. Shelfforce provides two discovery mechanisms:

OpenAPI specification

The full OpenAPI 3.1 specification is available at:
Use this spec for automatic tool generation in frameworks like LangChain, CrewAI, AutoGen, or the OpenAI/Anthropic function calling APIs. The spec includes all endpoints, request/response schemas, authentication requirements, and example values.

llms.txt

For LLM context injection, Shelfforce publishes an llms.txt file:
This file describes Shelfforce capabilities, endpoints, and usage patterns in natural language — optimized for LLM comprehension. Include it in your agent’s system prompt or retrieval context to help the model understand how to use the API. A more detailed version is available at:
The standard workflow for an AI agent integrating with Shelfforce:
1

Analyze

Submit a shelf image for analysis.
2

Poll or listen

Either poll GET /api/v1/analyses/{id} until status is completed, or configure a webhook for analysis.completed.
3

Extract

Read the product data from the completed analysis response. Parse brand names, facing counts, prices, and promotional status.
4

Report

Query share-of-shelf and store performance reports for aggregated insights.
5

Act

Based on the results, the agent can create tasks, flag compliance issues, or feed data into downstream systems.

Function calling schema

Here is an example tool definition for Claude or GPT function calling that covers the core analysis workflow:
Additional tool definitions your agent may need:

Idempotency keys

Idempotency is critical for AI agents, which may retry requests due to timeouts, network errors, or reasoning loops. Always include an idempotency key with analysis requests:
If the same idempotency key is sent again within 24 hours, Shelfforce returns the existing analysis rather than creating a duplicate. This prevents wasted credits and duplicate data.
Without idempotency keys, agent retries will create duplicate analyses and consume additional credits. Always include them in automated pipelines.

Webhook-driven vs. polling

There are two patterns for handling asynchronous analysis results:

Polling (simpler, good for agents)

Polling is straightforward and works well for agents that maintain a single execution thread. Poll every 3-5 seconds. Analyses typically complete in 10-30 seconds.

Webhook-driven (more efficient, better for production)

Webhooks are more efficient for production systems that process many images. Register a webhook for analysis.completed, and your system receives the results as soon as they are ready — no wasted requests.
For agents that need to wait for results inline (e.g., in a tool call), polling is simpler. For background pipelines or multi-step workflows, webhooks are recommended.

Error handling for agents

AI agents should handle Shelfforce errors gracefully:

Example: Agent error handling loop

MCP server (coming soon)

A Model Context Protocol (MCP) server for Shelfforce is on the roadmap. This will allow Claude Desktop, Cursor, and other MCP-compatible clients to discover and use Shelfforce tools automatically.

Best practices for agents

Always use idempotency keys

Prevents duplicate analyses and wasted credits when agents retry requests.

Include metadata

Tag analyses with source, agent name, and context so you can trace which agent submitted which analysis.

Handle all error codes

Distinguish between retryable (429, 500) and non-retryable (401, 402, 403, 422) errors.

Cache analysis results

Analysis results are permanent. Store results locally to avoid redundant GET requests.

Use llms.txt for context

Include the llms.txt content in your agent’s system prompt for better API understanding.

Respect rate limits

Implement exponential backoff. Use batch endpoints to reduce request count.