Skip to main content

Agent API examples

List available models

GET https://api.llmtune.io/api/agent/v1/models
Authorization: Bearer sk_live_YOUR_KEY
Example response:
{
  "object": "list",
  "data": [
    {
      "id": "meta-llama/Llama-3.3-70B-Instruct",
      "name": "Llama 3.3 70B",
      "owned_by": "Meta"
    }
  ]
}
Use one of the id values as the model in chat requests.

Chat with tools

Request:
curl https://api.llmtune.io/api/agent/v1/chat/completions \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meta-llama/Llama-3.3-70B-Instruct",
    "messages": [
      { "role": "user", "content": "Read the file src/index.ts" }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "read_file",
          "parameters": { "path": "string" }
        }
      }
    ],
    "tool_choice": "auto",
    "temperature": 0.7,
    "max_tokens": 1000
  }'
Example response (model requests a tool call):
{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_1",
            "type": "function",
            "function": {
              "name": "read_file",
              "arguments": "{\"path\": \"src/index.ts\"}"
            }
          }
        ]
      }
    }
  ]
}

Sending tool results back

After executing the tool (e.g. reading the file), send the result as a message and call the API again:
{
  "model": "meta-llama/Llama-3.3-70B-Instruct",
  "messages": [
    { "role": "user", "content": "Read the file src/index.ts" },
    {
      "role": "assistant",
      "content": null,
      "tool_calls": [
        {
          "id": "call_1",
          "type": "function",
          "function": {
            "name": "read_file",
            "arguments": "{\"path\": \"src/index.ts\"}"
          }
        }
      ]
    },
    {
      "role": "tool",
      "tool_call_id": "call_1",
      "content": "// file contents here..."
    }
  ],
  "tools": [...],
  "tool_choice": "auto",
  "max_tokens": 1000
}
The model then continues with the next reply (text or more tool calls). Repeat until the model returns a normal text response with no tool calls.

Interacting with files

  • read_file — Client reads the file at the given path and sends the contents in the tool message.
  • write_file — Client writes the given contents to the path and can confirm success in the tool message.
  • list_directory — Client lists the directory and returns the listing as the tool result.
The platform does not have access to your filesystem; all file operations are performed by your client based on the tool calls returned by the API.