HTTP Integration

The HTTP integration allows you to send events to the LLMonitor API endpoint. This is useful if you want to integrate LLMonitor with a custom language where our SDKs are not available.

The endpoint accepts POST requests with a JSON body containing an array of Event objects.

Endpoint

https://app.llmonitor.com/api/v1/report

Authentication

There is no authentication required to send events to the API endpoint. However, you will need to provide valid app IDs in the Event object or the request will be rejected.

Example

Here is an example with cURL to send a POST request to the API endpoint:

curl -X POST 'https://app.llmonitor.com/api/v1/report' \
-H 'Content-Type: application/json' \
-d '{
"events": [
{
"type": "llm",
"app": "YOUR APP ID",
"event": "start",
"runId": "some-unique-id",
"name": "gpt-3.5-turbo",
"timestamp": "2022-01-01T00:00:00Z",
"input": [{"role": "user", "text": "Hello world!"}],
"tags": ["tag1"]
}
]
}'

Once your LLM call succeeds, you would need to send an end event to the API endpoint with the output data from the LLM call.

Input / output format

You can use any valid JSON for the input & output fields.

However, for LLM calls you can use the chat message format:

Example:

[{
"role": "system",
"text": "You are an assistant"
}, {
"role": "user",
"text": "Hello world!"
}, {
"role": "ai",
"text": "Hello. How are you?"
}]

Event definition

The Event object has the following properties:

PropertyTypeRequiredDescription
typestringYesThe type of the event. Can be one of "llm", "agent", "tool", "chain", "chat", "convo".
appstringYesThe app ID of the application.
eventstringNoThe name of the event. Can be one of "start", "end, "error", "feedback",
runIdstringYesThe ID of the run (UUID recommended)
parentRunIdstringNoThe ID of the parent run, if any.
timestampstringYesTimestamp in ISO 8601 format.
inputanyNoInput data (with start events)
tagsstring[]NoArray of tags.
namestringNoThe name of the current model, agent, tool, etc.
outputanyNoOutput data (with end events)
extraanyNoExtra data associated with the run.
feedbackanyNoFeedback data associated with the run (only when type = 'feedback')
tokensUsageobjectNoAn object containing the number of prompt and completion tokens used (only for llm run)
errorobjectNoAn object containing the error message and stack trace if an error occurred.

The tokensUsage object has the following properties:

PropertyTypeRequiredDescription
promptnumberNoThe number of prompt tokens used.
completionnumberNoThe number of completion tokens used.

If tokensUsage is not provided, the number of tokens used will be calculated from the input and output fields. This works with models from OpenAI, Anthropic and Google at the moment.

The error object has the following properties:

PropertyTypeRequiredDescription
messagestringYesThe error message.
stackstringNoThe stack trace of the error.

For the feedback field, refer to the Feedback page for more information.

Questions? We're here to help.