Forefront
  • Get started
    • Introduction
    • Quickstart
    • Models
    • Tutorials
  • Features
    • Text generation
    • Fine-tuning
    • Datasets
    • Pipelines
    • Export models
    • Import from HuggingFace
  • API Reference
    • Introduction
    • Authentication
    • Chat
    • Completions
    • Fine-tuning
    • Pipeline
    • Troubleshooting
Powered by GitBook
  1. API Reference

Completions

Given a prompt, the model will return a completion.

Create completion

POST https://api.forefront.ai/v1/chat/completions

Creates a model response for the given chat conversation.

Request Body

Name
Type
Description

model*

string

prompt*

string

max_tokens

integer

temeperature

number

stop

array

{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Of course! I'm here to help..."
      }
    }
  ],
  "usage": {
    "input_tokens": 28,
    "output_tokens": 10,
    "total_tokens": 38
  },
  "message": {
    "content": "Of course! I'm here to help."
  }
}

Example request

from forefront import ForefrontClient

ff = ForefrontClient(api_key="YOUR_API_KEY")

completion = ff.chat.completions.create(
    prompt="Write a recipe for an italian dinner",
    model="MODEL_STRING", # replace with model string
    temperature=0,
    max_tokens=10,
)
import Forefront from "forefront";

const client = new Forefront("YOUR_API_KEY");

const completion: any = await client.chat.completions.create({
  model: "MODEL_STRING",
  prompt: "Write a recipe for an italian dinner",
  max_tokens: 256,
  stream: false,
});
curl https://api.forefront.ai/v1/chat/completions \
--header 'content-type: application/json' \
--header 'authorization: Bearer $FOREFRONT_API_KEY' \
--data '{
    "model": "REPLACE_WITH_MODEL_STRING",
    "prompt": "What is the meaning of 42?",
    "temperature": 0.1,
    "max_tokens": 128,
}'

Last updated 1 year ago