Chat

Chat completion

Generate a chat completion using an LLM via OpenRouter. Supports multiple model providers (Anthropic, OpenAI, Perplexity). Credits charged dynamically based on token usage.

post/chat/completions

Request

  • Base URL: https://studio.fintechstudios.com/api/v1
  • URL: https://studio.fintechstudios.com/api/v1/chat/completions
  • Auth: one of:
    • API key in header X-API-Key
    • HTTP bearer

Request body

modelstring required

Model ID from /models endpoint

max_tokensinteger
temperaturenumber
provider_paramsobject

Provider-specific request parameters forwarded to the upstream LLM via OpenRouter. Known Perplexity params: return_images (boolean), return_related_questions (boolean), search_recency_filter (string: 'month'|'week'|'day'|'hour'), search_domain_filter (string[]).

enrich_citationsboolean

When true, post-process provider metadata to extract a structured citations array as a sibling to provider_metadata. Currently resolves Perplexity citation URLs into objects with url, title, source_name, and date. Raw provider_metadata is never modified. Response content [n] references are preserved as-is for apps to render as they choose.

normalize_imagesboolean

When true, normalize provider-specific image metadata into a consistent schema. Maps variant field names (image_url/url/src, origin_url/source_url/page_url) to stable fields: url, source_url, width, height, alt, source_domain. Deduplicates by URL. Raw provider_metadata.images is never modified.

Example request

{
  "model": "anthropic/claude-sonnet-4-20250514",
  "provider_params": {
    "return_images": true,
    "return_related_questions": true,
    "search_recency_filter": "week"
  }
}

Response

Chat completion response

Example response

{
  "data": {
    "id": "chatcmpl-abc123",
    "object": "chat.completion",
    "citations": [
      {
        "index": 1,
        "url": "https://reuters.com/article/...",
        "title": "Tesla Q3 Report Beats Estimates",
        "source_name": "Reuters",
        "date": "2025-10-18"
      },
      {
        "index": 2,
        "url": "https://bloomberg.com/news/...",
        "title": "EV Market Analysis - Bloomberg",
        "source_name": "Bloomberg",
        "date": "2025-10-17"
      }
    ],
    "images": [
      {
        "url": "https://images.reuters.com/tesla-factory.jpg",
        "source_url": "https://reuters.com/article/...",
        "width": 1280,
        "height": 720,
        "alt": "Tesla Gigafactory",
        "source_domain": "reuters.com"
      }
    ]
  },
  "meta": {
    "request_id": "req_abc123def456",
    "credits_used": 1,
    "credits_remaining": 199,
    "rate_limit": {
      "limit": 1000,
      "remaining": 999,
      "reset": 1709251200
    }
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.