# Maniac: Continually optimizing models from your LLM telemetry and evals.

Maniac is an enterprise AI platform that makes it easy to replace existing LLM API calls with fine-tuned, task-specific models. Drop in Maniac with one line of code to:

* Capture and structure production **LLM traffic**
* Automatically **fine-tune** and **evaluate** Small Language Models (SLMs) on your tasks
* **Replace over-generalized LLM calls** with higher performance, lower latency models built for just what you need
* **Focus engineering time where it matters most:** building and refining high-quality model evaluations—not managing infrastructure, hyperparameters, or bespoke fine-tuning pipelines

All with virtually no changes to your existing codebase.

## Getting started

{% stepper %}
{% step %}
**Sign up for Maniac**

Head over to <https://app.maniac.ai/auth/register>
{% endstep %}

{% step %}
**Create a new Organization**

Organizations house multiple projects.
{% endstep %}

{% step %}
**Add a Project**

All your work — containers, evals, and deployments — live here.
{% endstep %}

{% step %}
**Generate an API key**

From your project settings
{% endstep %}
{% endstepper %}

{% embed url="<https://youtu.be/gTcfZSXy4hM>" %}

***

## Dropping Maniac into your Codebase

#### Set environment variables

```python
export MANIAC_API_KEY="your-api-key"
export MANIAC_BASE_URL="https://platform.maniac.ai/api/v1
```

Containers log inference and automatically build datasets for fine-tuning and evaluation. <mark style="color:$info;">`initial_model`</mark> sets the model used in that container until a Maniac model is deployed in its place.

#### Create a container

```python
import os
import requests

BASE_URL = os.getenv("MANIAC_BASE_URL")
API_KEY = os.getenv("MANIAC_API_KEY")

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/containers",
    headers=headers,
    json={
        "label": "my-container",
        "initial_model": "openai/gpt-5.2",
        "api": "chat.completions",
        "default_system_prompt": "You are a helpful math tutor.",
    },
)

response.raise_for_status()
container = response.json()

print("Created container:", container["label"])
```

#### Generating Inference Logs

Now that you've made a container, let's add some data to it. You can either register completions with any existing provider, or run inference through Maniac. In both cases, inference logs will auto-populate in your container. External datasets can also be [manually uploaded](/datasets/upload-datasets.md).

{% tabs %}
{% tab title="Registering Completions" %}

```python
import os
import requests

BASE_URL = os.getenv("MANIAC_BASE_URL")
API_KEY = os.getenv("MANIAC_API_KEY")

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

_input = {
  "model": "openai/gpt-5.2"
  "messages": [{
    "role": "user",
    "content": "Hello!"
  }]
}

_output = some_other_provider.chat.completions.create(**params)

requests.post(
    f"{BASE_URL}/chat/completions/register",
    headers=headers,
    json={
        "container": "my-container",
        "items": [
            "input": _input,
            "output": _output
        ],
    },
)
```

{% endtab %}

{% tab title="Running Inference Through Maniac" %}

```python
response = requests.post(
    f"{BASE_URL}/chat/completions",
    headers=headers,
    json={
        "model": "maniac:my-container",
        "messages": [
            {
                "role": "user",
                "content": "A train travels 120 miles in 2 hours. What is its average speed?"
            }
        ],
    },
)

response.raise_for_status()
completion = response.json()

print(completion["choices"][0]["message"]["content"])
# Output: "The average speed is 60 miles per hour. This is calculated by dividing distance (120 miles) by time (2 hours): 120 ÷ 2 = 60 mph."
```

{% endtab %}
{% endtabs %}

> **Note:** We recommend defining the system prompt at the **container level**. All inference requests executed through that container will automatically inherit this system prompt. If a request’s `messages` array includes its own system prompt, it will override the container-level system prompt for that request only.

{% embed url="<https://youtu.be/5ygzMi4okJ8>" %}

***

## Optimizing your model

The inference logs in your container now serve as training data for a new SLM—fully yours, lower latency, cheaper, and optimized specifically for your task.

{% stepper %}
{% step %}

#### Create an <mark style="color:green;">Eval</mark>

Evaluations define the optimization target. They can be implemented as arbitrary code or defined using judge prompts.

From the **Evals** tab inside a container, **Add Eval**.

{% tabs %}
{% tab title="Judge Eval" %}

<div data-with-frame="true"><figure><img src="/files/GjGYGH2Wr6Ow1jqDpl3U" alt=""><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Code Eval" %}

<div data-with-frame="true"><figure><img src="/files/SmF0VWTrIFfY6rZr6Ex8" alt=""><figcaption></figcaption></figure></div>
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### <mark style="color:green;">Optimization</mark> happens automatically

Once your telemetry hooks and evals are in place, Maniac automatically optimizes a model for your task — no manual configuration required.
{% endstep %}
{% endstepper %}

***

## Deploy.

Optimized models can be be deployed into a container from the **Models** tab. Once deployed, you can chat with your generated models, and inference requests are now routed through the Maniac model instead of the <mark style="color:$info;">`initial_model`</mark>.

<div data-with-frame="true"><figure><img src="/files/uKOBHADOtNN0Ley3tEZ3" alt=""><figcaption></figcaption></figure></div>

### Need help?

:e-mail: Email us at <support@maniac.ai>

We'll get back to you within a day.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maniac.ai/getting-started/readme-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
