agentsvc.io

services / chat

textoperational · 506 ms

Chat Completions (Mistral Small 4, OpenAI format)

OpenAI-compatible chat completions from Mistral Small 4 (Mistral AI), paid per call: send messages, get choices with the assistant message, tool calls and token usage. Flat $0.003 per call for up to 11,000 characters of input (messages, tools and schema as JSON) and up to 800 output tokens. Supports system prompts, JSON mode, JSON schema output and function calling. Also at POST https://agentsvc.io/v1/chat/completions for the OpenAI SDK (model mistral-small-latest). Fast and cheap for agent steps, classification, rewriting, extraction and tool use. EU model: Mistral AI (France), GDPR processor agreement, API data is not used for training. Failed calls are not charged. Use is subject to the agentsvc.io terms and the Mistral AI Usage Policy.

Run free trial ↗3 free calls per day with the example input. Paid: $0.003 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/chat", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"messages":[{"role":"user","content":"What is the capital of France? One sentence."}],"max_tokens":50}),
});
const { data, payment } = await res.json();  // payment.status "settling"; header X-Payment-Settle: sync returns payment.transaction

Input

FieldTypeDescription
messagesarrayConversation in OpenAI format: [{"role": "system"|"user"|"assistant"|"tool", "content": "..."}]. Text only. Shortcut instead: prompt (+ system)
promptstringShortcut for a single user message (use instead of messages)
systemstringSystem prompt, only together with prompt
max_tokensintegerMax output tokens, capped at 800 (default 800)
temperaturenumber0 to 1.5
top_pnumber
seedinteger
stopstring,array
response_formatobject{"type": "json_object"} or {"type": "json_schema", "json_schema": {...}}
toolsarrayFunction tools in OpenAI format, max 32
tool_choicestring,objectauto, none, required or a named function

Output

FieldTypeDescription
idstring
objectstring
createdinteger
modelstring
choicesarray
usageobject
providerstring
limitsobject
noticestring

Example response (data)

{
  "id": "c4f6d32a98f54897bdd713c0f1a6cc09",
  "object": "chat.completion",
  "created": 1796396198,
  "model": "mistral-small-2603",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "tool_calls": null,
        "content": "The capital of France is Paris."
      }
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 8,
    "total_tokens": 33
  },
  "provider": "Mistral AI",
  "limits": {
    "max_input_chars": 11000,
    "max_tokens": 800
  },
  "notice": "AI-generated by a Mistral AI model via agentsvc.io. Use is subject to https://agentsvc.io/terms#ai-chat and the Mistral AI Usage Policy (https://legal.mistral.ai/terms/usage-policy). Do not present it as written by a human."
}