Skip to main content
The Agents API is the next generation of our API, designed for better compatibility with modern AI SDKs like the Vercel AI SDK.

Overview

The Agents API represents a significant improvement over the Assistants API, with the main goal of providing native compatibility with industry-standard AI SDKs. The key difference is the removal of custom input/output transformations in favor of standard formats.

Why Migrate?

  • Vercel AI SDK compatibility: Works natively with AI SDK 5’s useChat function
  • Standard formats: Uses industry-standard message formats instead of custom transformations
  • Better streaming: Native support for AI SDK streaming patterns
  • Future-proof: The Assistants API will be deprecated on 16 August

Key Differences

Endpoint Changes

Parameter Changes (Non-Breaking)

For create, get, and update endpoints, the only change is parameter naming:
  • assistantIdagentId
  • Request/response structure remains identical
  • All other parameters unchanged

Breaking Changes in /chat/completions

The chat completions endpoint has significant format changes to support Vercel AI SDK compatibility.

Request Format Changes

Old Format (Assistants API)

New Format (Agents API)

Key Request Differences

  1. Message Structure:
    • Old: content as string
    • New: parts as array with typed objects
  2. Message ID:
    • Old: Optional or auto-generated
    • New: Required id field for each message
  3. Attachments:
    • Old: attachmentIds array at message level
    • New: metadata.attachments array on the message object
  4. Parameter Name:
    • Old: assistantId
    • New: agentId

Response Format Changes

Old Format (Assistants API)

New Format (Agents API)

Key Response Differences

  1. Top-level Structure:
    • Old: Wrapped in result array
    • New: Wrapped in messages array
  2. Content Field:
    • Old: content array
    • New: content string

Streaming Changes

Old Format (Assistants API)

New Format (Agents API)

Uses Vercel AI SDK streaming format:
The Agents API streams in Vercel AI SDK’s native format, compatible with the useChat hook.

Migration Steps

Step 1: Update Endpoint URLs

Step 2: Update Parameter Names (Non-Breaking Endpoints)

For create, get, update endpoints:

Step 3: Update Message Format (Breaking - Chat Completions)

Converting Messages

Using with Vercel AI SDK

The Agents API works natively with Vercel AI SDK’s useChat hook:

Step 4: Update Response Handling

Step 5: Update Streaming Code

Before (Custom SSE Parsing)

After (Vercel AI SDK)

Code Examples

Complete Migration Example

Before (Assistants API)

After (Agents API)

Using with Next.js and Vercel AI SDK

Testing Your Migration

Checklist

  • Update all endpoint URLs from /assistant/v1/* to /agent/v1/*
  • Replace assistantId with agentId in all requests
  • Convert message content strings to parts arrays (for chat completions)
  • Add id field to all messages (for chat completions)
  • Update attachment references to use metadata.attachments format
  • Update response handling to work with new format
  • Test streaming with new format (or use Vercel AI SDK)
  • Update error handling for new response structure
  • Notify owners or migrate systems that use API keys marked Using deprecated endpoints in workspace API settings

Gradual Migration Strategy

You can migrate endpoints gradually:
  1. Start with non-breaking endpoints: Migrate create, get, update, models first (only parameter names change)
  2. Test thoroughly: Ensure these work correctly
  3. Migrate chat completions last: This requires the most code changes
  4. Use feature flags: Toggle between old and new APIs during transition

Common Migration Issues

Issue 1: Missing Message IDs

Problem: Agents API requires message IDs
Solution: Generate unique IDs for each message

Issue 2: Attachment Format

Problem: Old attachment format not recognized
Solution: Use metadata.attachments

Issue 3: Response Parsing

Problem: Looking for result array
Solution: Use messages array with content string

Support

If you encounter issues during migration:
  1. Check the Agents API documentation for detailed examples
  2. Review the Vercel AI SDK documentation for SDK-specific help
  3. Contact support at support@langdock.com

Timeline

  • Current: Both APIs are available
  • Future: Assistants API will be deprecated on 16 August
  • Recommendation: Migrate new systems to Agents API now
For questions or assistance with migration, contact our support team at support@langdock.com.