Skip to main content
Deprecation Notice: The Chat and Message API endpoints are being deprecated. Please migrate as soon as possible.
Choosing your migration target: If you don’t need routing, model_family, or grounded completions, migrate directly to the Responses API — Gloo’s recommended, OpenAI-compatible surface, with guardrails and tradition included. If you do need those features, this guide’s path to Completions V2 is the right choice. The request/response mapping below adapts to either; see the Completions → Responses field mapping.

Overview

The Chat and Message API provided a convenient stateful approach to building conversational AI, with automatic session management and history tracking. As we evolve the Gloo platform, we’re transitioning to the Completions v2 API powered by a layered, production-ready AI architecture. This is a more flexible architecture that gives you complete control while delivering values-aligned AI with intelligent model routing. This guide will help you migrate your existing Chat API integrations to Completions v2, maintaining all the conversational capabilities you need while gaining access to powerful new features.

Why Migrate to Completions v2?

Values-Aligned Infrastructure

Access AI infrastructure built for human flourishing with values alignment and safety at every layer

Intelligent Routing

Auto-routing, model family selection, or direct model choice—optimize for quality, cost, and intent

Full Control

Manage conversation state, history, and context exactly how your application needs it

Theological Alignment

Built-in support for tradition-aware responses (evangelical, catholic, mainline)

Quick Start: Minimal Migration Path

If you want to get started quickly, here’s the fastest path to migrate:
1

Update your endpoint

Change from /ai/v1/message to /ai/v2/chat/completions
2

Set up conversation storage

Create a simple database table for storing chat history
3

Build conversation history

Fetch messages from your database and format them for Completions v2
4

Call Completions v2 with auto-routing

Let Gloo automatically select the best model

Understanding the Changes

Architecture Comparison

Gloo managed:
  • Chat session creation
  • Message storage
  • History retrieval
  • Context management

Key Differences

Step-by-Step Migration Guide

Step 1: Design Your Conversation Storage

The first step is creating your own storage for conversations. Here’s a recommended schema that mirrors the Chat API’s capabilities:
Pro Tip: Include fields for tradition, model, and tokens_used to track theological alignment, model usage patterns, and costs over time.

Step 2: Build Conversation Management

Create functions to manage chat sessions and messages:

Step 3: Integrate with Completions v2

Now integrate your conversation manager with the Completions v2 API:

Step 4: Migrate Existing Chat Data

Before the Chat API is deprecated, export your existing conversations:
Important: Run your migration script as soon as you can to ensure all data is safely transferred. Test thoroughly with a subset of users first.

Leveraging Completions v2 Features

1. Intelligent Model Routing

Take advantage of Gloo’s routing capabilities:
Let Gloo automatically select the optimal model:
Best for: Quick prototyping or when you prefer hands-off model management

2. Tradition-Aware Responses

Maintain theological alignment throughout conversations:

3. Streaming Responses

Implement real-time streaming for better UX:

Advanced Patterns

Pattern 1: Conversation Branching

Create alternative conversation paths:

Pattern 2: Multi-Source Integration

Leverage multiple content publishers:

Pattern 3: Conversation Summarization

Auto-summarize long conversations:

Testing Your Migration

Unit Tests

Integration Tests

Troubleshooting

Problem: API returns error about token limitSolution: Implement proper context truncation in your getConversationHistory method:
For models with smaller context windows, consider conversation summarization to maintain essential context while reducing token count.
Problem: Messages appearing in wrong chronological orderSolution: Ensure your database queries always sort by created_at ascending:
Also use transactions when writing multiple messages to prevent race conditions.
Problem: Responses don’t reflect the specified theological traditionSolution: Verify tradition is being passed to Completions v2:
Problem: Responses taking too longSolutions:
  1. Use Streaming: Provides immediate feedback to users
  2. Optimize Context: Only send necessary messages
  3. Cache Recent Conversations: Use Redis for hot data
  4. Choose Appropriate Models: Use model family selection
Problem: Race conditions with simultaneous messagesSolution: Use database transactions and row-level locking:

Migration Checklist

1

Planning & Design

  • Review current Chat API usage patterns
  • Design database schema for conversations
  • Plan context window management strategy
  • Decide on model routing strategy (direct model selection recommended)
  • Identify which chats need tradition parameter
  • Create migration timeline
2

Development

  • Set up conversation storage (PostgreSQL/MongoDB)
  • Implement ConversationManager class
  • Integrate GlooCompletionsV2Client
  • Build ChatService combining both
  • Add context window management
  • Implement error handling and retries
  • Add logging and monitoring
  • Set up streaming support (optional)
3

Testing

  • Write unit tests for conversation management
  • Write integration tests for full chat flows
  • Test with various message lengths
  • Test context window truncation
  • Test concurrent request handling
  • Verify tradition parameter works correctly
  • Load test with production-like volumes
4

Data Migration

  • Create data export script
  • Export existing chats from Chat API
  • Validate exported data
  • Import into new system
  • Verify data integrity
  • Test sample conversations work correctly
5

Deployment

  • Deploy new infrastructure
  • Run migration script for all users
  • Enable new system for subset of users
  • Monitor performance and errors closely
  • Gradually roll out to all users
  • Keep Chat API as fallback initially
6

Cutover

  • Switch all traffic to new system
  • Monitor for 48 hours
  • Disable Chat API integrations
  • Update documentation
  • Communicate completion to team
  • Celebrate! 🎉

Benefits of Migrating

Values-Aligned AI

Built-in values alignment and safety at every layer

Intelligent Routing

Auto-routing optimizes every query for quality, cost, and intent automatically

Full Control

Complete control over storage, retention, context management, and conversation workflows

Theological Alignment

Native support for tradition-aware responses (evangelical, catholic, mainline)

Advanced Features

Build sophisticated UX with branching, editing, summarization, and more

Cost Optimization

Control what context you send and optimize token usage based on your needs

Better Performance

Optimize with caching, indexing, and custom logic for your specific use case

Enhanced Privacy

Keep sensitive conversations in your own infrastructure with full control

Support and Resources

Migration Support

Email our team for migration assistance

Completions v2 Docs

Complete API reference for Completions v2

Chat API Reference

Reference for the deprecated Chat API

Tool Use Guide

Enhance your completions with tool calling

Next Steps

Review Architecture

Understand the architectural changes

Follow Migration Steps

Work through the detailed migration guide

Test Your Integration

Set up testing before going to production
Questions about migration? We’re here to help! Reach out to hello@gloo.us or use the support link in the top navigation.