1For AI
  • Welcome
  • Getting Started
    • Quickstart
  • Model
    • Retrieve Model List
    • Get Single Model
  • Chat
    • Create new chat
    • Continue Chat Conversation
  • User
    • User Balance
  • Errors
    • Common Errors
Powered by GitBook
On this page
  1. Chat

Continue Chat Conversation

API Documentation: Continue Chat Conversation

Endpoint

POST /v1/chat/completions/:chat_id

Description

This endpoint continues an existing conversation using the provided chat_id. It works similarly to /v1/chat/completions, but allows you to maintain conversation context.

Request

cURL Example:

curl --location 'https://api.1for.ai/v1/chat/completions/{chat_id}' \
--header 'Content-Type: application/json' \
--header 'api-key: {API_KEY}' \
--data '{
  "messages": [
    {"role": "user", "content": "Can you explain further?"}
  ]
}'

Replace {API_KEY} with your actual API key and {chat_id} with the ID of the existing chat session.

Request Body:

  • messages: (array) A list of message objects:

    • role: (string) "user", "system".

    • content: (string) The text content of the message.

Response

The response will be a JSON object similar to /v1/chat/completions:

{
    "text": String,
    "cost": Double,
    "role": "system",
    "chat_id": String,
    "model": String
}
  • text: The AI's generated continuation.

  • cost: The cost incurred for this completion.

  • role: The role of the response sender (usually "system").

  • chat_id: The ID of the ongoing conversation.

  • model: The model used to generate the response.

Notes

  • This endpoint automatically preserves previous conversation history associated with the chat_id.

  • Make sure the chat_id provided is valid and was generated by a prior /v1/chat/completions request.

  • If an invalid chat_id is provided, a 404 Not Found error will occur.

PreviousCreate new chatNextUser Balance

Last updated 1 month ago