Skip to main content
POST
/
forward
curl --request POST \
--url https://api.lavapayments.com/v1/forward \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful customer service assistant for a tech company."
},
{
"role": "user",
"content": "My laptop won'\''t turn on. What should I check first?"
}
],
"temperature": 0.7,
"max_tokens": 300
}'
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677858242,
"model": "gpt-3.5-turbo-0613",
"usage": {
"prompt_tokens": 13,
"completion_tokens": 7,
"total_tokens": 20
},
"choices": [
{
"message": {
"role": "assistant",
"content": "I'm doing well, thank you for asking! How can I assist you today?"
},
"finish_reason": "stop",
"index": 0
}
]
}

Authorizations

Authorization
string
header
required

Special authentication used for the forward endpoint. Requires a base64-encoded JSON object containing secret_key, connection_secret, and product_secret. Optionally include provider_key to use your own API key for the request. When using your own API key, you can make requests that use metering only by setting both connection_secret and product_secret to null. Format: 'Bearer BASE64_ENCODED_JSON'

Headers

x-lava-metadata
string

Optional metadata to associate with the request. Must be a JSON object with up to 100 key-value pairs, where both keys and values are strings between 1-255 characters. Keys must contain only ASCII letters, numbers, and underscores (no spaces or special characters). Alternative to metadata query parameter.

Query Parameters

u
string
required

The API endpoint URL to forward the request to

metadata
string

Optional metadata to associate with the request. Must be a JSON object with up to 100 key-value pairs, where both keys and values are strings between 1-255 characters. Keys must contain only ASCII letters, numbers, and underscores (no spaces or special characters). Alternative to x-lava-metadata header.

Body

application/json

Request body that will be forwarded to the AI provider API. Must include the 'model' field.

model
string
required

The model to use for the request

stream
boolean

Whether to stream the response

Response

Successful response from the provider API

Response from the provider API