Skip to main content
The chat() and chatStream() methods provide text generation with support for multimodal inputs, function calling, and streaming.

Basic Chat

Streaming

Stream responses token by token for better UX:
Use streaming for long responses to show progress to users instead of making them wait.

Message Roles

System Messages

Set behavior and context:

Conversation History

Include previous messages for context:

Vision (Multimodal)

Send images in messages:

Image Detail Levels

Multiple Images

Function Calling

Define tools the model can use:

Tool Choice Options

Complete Function Calling Example

JSON Mode

Force structured JSON output:
When using JSON mode, include “JSON” in your prompt to improve reliability.

Parameters

Request Parameters

Data Parameters

Temperature Guide

Response

Finish Reasons

Advanced

Override Model

Override the gate’s configured model:

Custom Metadata

Track requests with metadata:

Stop Sequences

Stop generation at specific strings:

End-user ID (experiment routing)

Pass endUserId when you want a stable end-user to consistently land in the same experiment variant across every request they make.
Any stable string works — an end-user ID, a session token, a device fingerprint. Two requests with the same endUserId always hash to the same variant; different values get independent assignments.
If an active experiment on the gate is configured with randomization_unit = 'user' and endUserId is missing, the request will bypass the experiment (and will not be counted as either variant). The experiment’s coverage metric in the dashboard shows how much traffic had the identifier. We’ll email you if 10 consecutive requests miss it.
Don’t use PII directly. Hash your user IDs or use opaque tokens. We hash whatever you pass and never expose it back externally, but it’s good hygiene.

Best Practices

1. Use Streaming for Long Responses

2. Always Handle Errors

3. Provide System Context

4. Monitor Costs

Examples

Customer Support Bot

Code Explanation

Image Analysis

Next Steps

Images

Generate images from text

Embeddings

Create text embeddings

Gates & Routing

How Verlon routes requests

Cost Tracking

Monitor spending