Chat Completion

Introduction

This API provides an AI-powered chat completion endpoint. It takes user messages and generates responses using a lightweight AI model. The API does not store user messages—all responses are generated in real-time and discarded after processing. To be frank, I'm too broke to pay for D1 storage for your messages.


Endpoint

POST  https://api.elliott.diy/v1/ai/chat/completions

Request Parameters

Parameter
Type
Required
Description

messages

Array

✅ Yes

A list of chat messages, where the last message is used for AI generation.

Example Request

curl -X POST  https://api.elliott.diy/v1/ai/chat/completions/ \
     -H "Content-Type: application/json" \
     -d '{
       "messages": [
         { "role": "user", "content": "Hello, how are you?" }
       ]
     }'

Response Format

  • Content-Type: application/json

  • Status Codes:

    • 200 OK – Successful response

    • 400 Bad Request – Invalid JSON or missing messages

    • 500 Internal Server Error – AI service is unavailable

Example Response

{
  "id": "cfai-12345678-1234-5678-1234-567812345678",
  "object": "chat.completion",
  "created": 1710766200,
  "model": "elliott-1",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "I'm doing great! How can I assist you?" },
      "finish_reason": "stop"
    }
  ]
}

Response Fields

Field
Type
Description

id

String

Unique identifier for the response.

object

String

Always "chat.completion".

created

Integer

UNIX timestamp of when the response was generated.

model

String

Always "elliott-1".

choices

Array

Contains AI-generated message(s).

message.role

String

Always "assistant".

message.content

String

The AI-generated response.

finish_reason

String

Indicates why the response stopped (e.g., "stop").


Model Information

  • Base Model Used: @hf/google/gemma-7b-it

  • Custom Model Name: "elliott-1" (I'm so creative)

  • The model generates responses based on the last user message in the request.

Last updated