Catalog/llm-few-shot-format

LLM

Few-shot example formatter API

Formats labeled input/output examples into a consistent few-shot prompt block (configurable labels, separators, and instructions) then appends the live query with an open output label — and reports the example count and token size. Answers 'how do I build a few-shot prompt from these examples?', 'how do I format examples for in-context learning?'.

Price$0.02per request
MethodPOST
Route/v1/llm/few-shot-format
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
llmfew-shotpromptexamplesin-contextformaticlagent
API URLhttps://x402.hexl.dev/v1/llm/few-shot-format
Integration docs
Example request
{
  "examples": [
    {
      "input": "2+2",
      "output": "4"
    },
    {
      "input": "3+3",
      "output": "6"
    }
  ],
  "query": "5+5"
}
Example response
{
  "prompt": "Input: 2+2\nOutput: 4\n\nInput: 3+3\nOutput: 6\n\nInput: 5+5\nOutput:",
  "exampleCount": 2,
  "tokens": 33
}
Input schema
{
  "type": "object",
  "required": [
    "examples",
    "query"
  ],
  "properties": {
    "examples": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "query": {
      "type": "string",
      "examples": [
        "5+5"
      ]
    },
    "inputLabel": {
      "type": "string",
      "default": "Input"
    },
    "outputLabel": {
      "type": "string",
      "default": "Output"
    },
    "separator": {
      "type": "string",
      "default": "\n\n"
    },
    "instructions": {
      "type": "string"
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}