Skip to main content

Chat & Completion Models

Learn about the two main types of language models available on AnyAPI: chat models designed for conversations and completion models for text generation tasks.

Model Types Overview

Chat Models

Chat models are designed for interactive conversations with a structured message format including system, user, and assistant roles.

Completion Models

Completion models are designed to continue or complete text based on a given prompt, operating on raw text input.

Key Differences

Chat Models

  • Structured conversation format
  • Role-based messages (system/user/assistant)
  • Built-in conversation context
  • Better for dialogue and Q&A

Completion Models

  • Raw text continuation
  • Single prompt input
  • Manual context management
  • Better for text generation tasks

Chat Models API

Chat models use the /v1/chat/completions endpoint with a messages array:

Message Roles

System Messages

Set the behavior and context for the AI assistant:

User Messages

Messages from the human user:

Assistant Messages

Previous responses from the AI (for conversation context):

Conversation Context Management

Building Conversation History

Managing Context Length

Advanced Chat Patterns

Multi-turn Reasoning

Role-based Conversations

Best Practices

1. System Prompt Design

2. Temperature Settings

3. Error Handling

Performance Optimization

Batch Processing

Model Selection Guide

When to Use Chat Models

✅ Best for:
  • Interactive conversations
  • Question-answering systems
  • Customer support chatbots
  • Multi-turn dialogues
  • Role-playing scenarios
  • Structured conversations

When to Use Completion Models

✅ Best for:
  • Text continuation
  • Creative writing
  • Code completion
  • Single-shot text generation
  • Template filling
  • Legacy integrations

Model Recommendations

Common Patterns

The Few-Shot Pattern

Chain of Thought Reasoning

Getting Started

Quick Start

Start building with chat models

API Reference

Explore the chat completions API

Use Cases

See real-world examples

Best Practices

Learn advanced techniques