Caller Interfaces
All AI provider implementations are registered inapi/integration-api/internal/caller/callers.go. There are four interfaces a provider can implement:
ChatCompletionOptions
ChatCompletionOptions is passed to both GetChatCompletion and StreamChatCompletion. It carries the request context, model parameters, tool definitions, and observability hooks.
Model Parameters
Model parameters are passed inChatCompletionOptions.ModelParameter as a map[string]interface{} keyed by "model.*" strings. The OpenAI caller maps these keys as follows:
| Key | Type | Description |
|---|---|---|
model.name | string | Model ID (e.g. gpt-4o, gpt-3.5-turbo) |
model.temperature | float64 | Sampling temperature (0.0–2.0) |
model.top_p | float64 | Nucleus sampling |
model.max_completion_tokens | int64 | Max tokens to generate |
model.frequency_penalty | float64 | Frequency penalty (-2.0–2.0) |
model.presence_penalty | float64 | Presence penalty (-2.0–2.0) |
model.seed | int64 | Deterministic sampling seed |
model.stop | string | Comma-separated stop sequences |
model.tool_choice | string | auto · required · none |
model.response_format | JSON | {"type": "json_object"} · {"type": "json_schema", ...} |
model.reasoning_effort | string | OpenAI reasoning effort (o-series models) |
model.service_tier | string | OpenAI service tier |
model.user | string | User identifier for abuse detection |
Tool Definitions
Function tool definitions are passed viaChatCompletionOptions.ToolDefinitions:
Reference Implementation — OpenAI
The OpenAI caller is the canonical reference. All other providers follow the same structure.Client initialization (openai.go)
Client initialization (openai.go)
"key" maps to the API key field in the credential form.StreamChatCompletion (llm.go)
StreamChatCompletion (llm.go)
- Tokens are streamed via
onStreamas they arrive — each call delivers one delta - Tool calls are accumulated and emitted when complete via
accumulate.JustFinishedToolCall() - Metrics (input/output tokens, first-token time) are emitted once via
onMetricswhen streaming is complete
Adding a New LLM Provider
Create the provider directory
| File | Purpose |
|---|---|
<provider>.go | Client struct, credential extraction, GetClient() |
llm.go | LargeLanguageCaller implementation |
verify-credential.go | Verifier implementation |
| File | Purpose |
|---|---|
embedding.go | EmbeddingCaller implementation |
Register in callers.go
Open No changes to any other service are required.
api/integration-api/internal/caller/callers.go and add a case to the router that creates the caller:Metrics
Every caller emits structured metrics viaonMetrics. These are stored in PostgreSQL and visible in the dashboard activity logs.
| Metric Name | Description |
|---|---|
INPUT_TOKEN | Prompt tokens consumed |
OUTPUT_TOKEN | Completion tokens generated |
TOTAL_TOKEN | Total tokens (input + output) |
FIRST_TOKEN_RECIEVED_TIME | Time from request start to first token (TTFT) |