---
title: "Generate AI text with failover"
method: POST
path: "/ai/generate-text"
tags: ["AI Services"]
---

# Generate AI text with failover

`POST /ai/generate-text`

## Request

- Base URL: `https://us-central1-paymentgateway-ab783.cloudfunctions.net/api`
- URL: `https://us-central1-paymentgateway-ab783.cloudfunctions.net/api/ai/generate-text`
- Auth: HTTP bearer

Generate long-form or transactional text with automatic failover across Groq, GLM, DeepSeek, and Gemini models.

**For AI agents**: Use this endpoint for content generation tasks like blog posts, customer emails, sales copy, or conversational replies.

## Headers

- `x-app-id` string, required

## Request body

- object
  - `prompt` string, required: Natural language instruction or content request.
  - `maxTokens` integer: Maximum tokens to generate (1-8000).
  - `temperature` number: Creativity level from 0 (deterministic) to 2 (creative).
  - `timeout` integer: Timeout in milliseconds before failover triggers.

## Response `200`

Text generated successfully

- object
  - `content` string: Generated text output.
  - `provider` string: Upstream AI provider that produced the response.
  - `model` string
  - `duration` number: Processing time in milliseconds.

## Other responses

- `401`: Missing or invalid authentication token
- `429`: Rate limit exceeded
- `500`: Upstream providers unavailable or internal error

---

[API](https://skmtc.dev/futuresenseai/apis/futuresense-ai-central-hub-api.md) · [All operations](https://skmtc.dev/futuresenseai/apis/futuresense-ai-central-hub-api/llms.txt) · [OpenAPI document](https://skmtc.dev/futuresenseai/apis/futuresense-ai-central-hub-api/revisions/53e075911af9?raw)
