Continue Chat Conversation
API Documentation: Continue Chat Conversation
Endpoint
POST /v1/chat/completions/:chat_idDescription
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_idprovided is valid and was generated by a prior/v1/chat/completionsrequest.If an invalid
chat_idis provided, a404 Not Founderror will occur.
Last updated