Skip to main content

Overview

The Chat Completions endpoint allows UserTrace to interact with your custom chat agents using the OpenAI Chat Completions format. This is the primary endpoint for text-based agent testing.

Endpoint

Request Headers

Request Body

array
required
Array of message objects representing the conversation history
string
Unique identifier for the simulated user. Optional if your agent doesn’t require user management.
string
Session identifier for conversation tracking. Optional if your agent doesn’t require session management.
object
Additional context about the simulation scenario

Request Examples

Minimal Request

Full Request with Context

Response Format

array
required
Array containing the agent’s response
string
Session identifier echoed from request
string
Unique identifier for this conversation
object
Agent performance metrics
object
Additional data for evaluation purposes

Response Examples

Basic Response

Response with Tool Calls

Error Responses

400 Bad Request

429 Rate Limit

500 Internal Error

Implementation Notes

Tool Calling

If your agent uses function calling, you must handle all tool execution internally. The simulated user will send simple text requests, and your agent should:
  1. Execute any necessary function calls
  2. Include complete tool call information in the response
  3. Provide the final answer incorporating tool results

Performance Requirements

  • Response Time: Target < 5 seconds for standard requests
  • Throughput: Support 100 RPS for parallel simulations
  • Availability: 99.9% uptime during testing windows

Best Practices

  • Include relevant evaluation_metadata to help with scoring
  • Use consistent session_id for multi-turn conversations
  • Handle edge cases gracefully with appropriate error responses
  • Log requests and responses for debugging
Testing: Use tools like curl, Postman, or our SDK to test your endpoint before connecting to UserTrace.