Skip to content

Chat Generate API

Generate AI-powered text responses using the Recoup chat system. This endpoint processes chat requests and returns generated text along with metadata about the generation process.

Endpoint

POST https://chat.recoupable.com/api/chat/generate

Authentication

All requests to this endpoint must be authenticated using an API key header:

HeaderTypeRequiredDescription
x-api-keystringYesYour Recoup API key. See Getting Started for how to create and manage keys.

Parameters

NameTypeRequiredDescription
promptstringNoSingle text prompt for the assistant. Required if messages is not provided.
messagesarrayNoArray of UIMessage objects for context. Required if prompt is not provided.
artistIdstringNoThe unique identifier of the artist (optional)
modelstringNoThe AI model to use for text generation (optional)
excludeToolsarrayNoArray of tool names to exclude from execution (e.g., ["create_scheduled_actions"])

Exactly one of messages or prompt should be provided in each request.

Request Examples

cURL
curl -X POST "https://chat.recoupable.com/api/chat/generate" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "prompt": "Hello, how are you?",
    "model": "openai/gpt-5-mini",
    "excludeTools": ["create_scheduled_actions"]
  }'

Example Response

{
  "text": [
    {
      "type": "text",
      "text": "Hello! I'm here to help you with any questions or tasks you might have. How can I assist you today?"
    }
  ],
  "reasoningText": "The user greeted me, so I should respond with a friendly greeting and offer to help.",
  "sources": [],
  "finishReason": "stop",
  "usage": {
    "inputTokens": 8365,
    "outputTokens": 106,
    "totalTokens": 8471,
    "reasoningTokens": 64,
    "cachedInputTokens": 0
  },
  "response": {
    "messages": [],
    "headers": {},
    "body": {}
  }
}

Response Properties

PropertyTypeDescription
textArray<ContentPart<TOOLS>>Array of content parts from the AI model response. Learn more about ContentPart types
reasoningTextstringOptional reasoning or explanation for the response
sourcesarrayOptional array of sources used for the response
finishReasonstringThe reason why the generation finished
usageobjectToken usage information with detailed breakdown
usage.inputTokensnumberNumber of input tokens processed
usage.outputTokensnumberNumber of output tokens generated
usage.totalTokensnumberTotal tokens used (input + output)
usage.reasoningTokensnumberNumber of reasoning tokens used
usage.cachedInputTokensnumberNumber of cached input tokens
responseobjectAdditional response metadata and information

Notes

  • The text field contains an array of content parts that need to be processed to extract the actual text content
  • Use the finishReason to determine if the generation completed successfully
  • The usage object provides detailed token consumption information for cost tracking
  • The reasoningText field contains the AI model's internal reasoning process