Chat with an AI and ask questions in plain words
POST /v1/ai/chat
About this tool · Open it in the Studio
What it does
This is a plain text chat with an AI. You write a message and it answers. It cannot open your files or look things up on the internet, so paste any text you want it to use. You can choose which AI model answers. The AI can make mistakes, so check important answers.
How to call it
Send a POST request to /v1/ai/chat with your API key in the X-Api-Key header. The parameters below go in the request body (or in the address of a GET request). Files, when the tool takes them, are sent as multipart form data. Every answer carries a Request-Id header: quote it if you contact support.
Parameters
| Parameter | Type | Default | What it does |
|---|---|---|---|
modelOptional | string | auto | "auto" (dynamically selected) or an explicit model id. |
on_unsupportedOptional | string | error | What to do when the chosen model cannot honour a parameter. errorignore |
fallbackOptional | boolean | — | Allow automatic fallback to another eligible model even when `model` is explicit. |
messagesRequired | array | — | The conversation so far, oldest first: each message has a role (system, user or assistant) and its content. |
generationOptional | object | — | Generation settings: temperature, max_tokens, top_p and seed. |
presetIdOptional | string | — | Apply a saved preset (create one with POST /v1/presets). Every value stored in the preset is used unless this request sets that field itself. The preset must have been saved for this same endpoint; requires an individual customer API key. |
validate_onlyOptional | boolean | false | true = check the request without running it. The answer is `{ validated: true, valid, errors[], files, estimate, limits }` instead of the endpoint's usual answer: `errors` lists every parameter or file the real call would reject, `estimate` is what it would count against your plan, and `limits` are the limits that apply to this endpoint for your key. Nothing is processed, no files are produced and no files are counted against the plan; the call itself counts as one request. The tool’s own checks run on it too, up to the point where processing would start; a problem that only shows while processing (a crop outside the image) is not found. Files given as a web address are not downloaded. |
appOptional | string | — | The name of the app that makes this call, for example "My shop importer". It is shown in your History next to the result, so you can tell which app did what. The official apps fill it in themselves (Davix H2I plugin, Davix H2I n8n node, Davix H2I Studio, Davix H2I Dashboard); when you leave it out, the official SDKs and plugins are recognised from their User-Agent. Up to 60 characters; control characters and angle brackets are removed. The header `X-Davix-App` does the same. It is only a label: it never changes what the call does. |
Use it from your code
cURL
curl -X POST "https://app.h2i.davixlabs.io/v1/ai/chat" \
-H "X-Api-Key: $DAVIX_H2I_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"auto","on_unsupported":"error","messages":[{"role":"system","content":"example"}]}'Node.js
const { DavixH2I } = require('@davixlabs/h2i-sdk');
const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.ai.chat({
"model": "auto",
"on_unsupported": "error",
"messages": [
{
"role": "system",
"content": "example"
}
]
});
console.log(result.data, result.requestId);PHP
<?php
require 'vendor/autoload.php';
$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->ai()->chat([
'model' => 'auto',
'on_unsupported' => 'error',
'messages' => [[
'role' => 'system',
'content' => 'example',
]],
]);
echo $result->requestId;