> For the complete documentation index, see [llms.txt](https://docs.aimlapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aimlapi.com/capabilities/models-comparsion.md).

# Model comparison

{% hint style="success" %}
Be sure to check out our [Comparisons section](https://aimlapi.com/comparisons) on the main site — where text, code, image, music, and other models go head-to-head in close matchups to determine the winners!
{% endhint %}

You can send the same request to two specific text models of your choice and compare the results.

Just select two models from the [Text Models (LLM) list](/api-references/model-database.md#text-models-llm), copy their Model IDs, and paste them into the `Specify the models to compare` section of this code example as the values for `model1` and `model2`.

Don't forget to also insert your [AIML API Key](https://aimlapi.com/app/keys) instead of `<YOUR_AIMLAPI_KEY>`:

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests
from openai import OpenAI

# API credentials
BASE_URL = "https://api.aimlapi.com/v1"
# insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
API_KEY = "<YOUR_AIMLAPI_KEY>"

# Specify the models to compare
model1 = "gpt-4o"
model2 = "MiniMax-Text-01"

def generate_joke(model):
    client = OpenAI(base_url=BASE_URL, api_key=API_KEY)
    
    system_prompt = "You are an AI assistant that only responds with jokes."
    user_prompt = "Why did the programmer break up with their keyboard?"
    
    response = client.chat.completions.create(
        messages=[
            {"role": "system", "content": system_prompt},
            {"role": "user", "content": user_prompt},
        ],
        model=model,
    )
    
    return response.choices[0].message.content

def main():
    for model in [model1, model2]:
        joke = generate_joke(model)
        print(f"--- {model} ---")
        print(f"USER: Why did the programmer break up with their keyboard?")
        print(f"AI  : {joke}")

if __name__ == "__main__":
    main()

```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
import fetch from "node-fetch";

// API credentials
const BASE_URL = "https://api.aimlapi.com/v1";
const API_KEY = "<YOUR_AIMLAPI_KEY>";

// Specify the models to compare
const model1 = "gpt-4o";
const model2 = "MiniMax-Text-01";

async function generateJoke(model) {
    const systemPrompt = "You are an AI assistant that only responds with jokes.";
    const userPrompt = "Why did the programmer break up with their keyboard?";

    const response = await fetch(`${BASE_URL}/chat/completions`, {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "Authorization": `Bearer ${API_KEY}`
        },
        body: JSON.stringify({
            model,
            messages: [
                { role: "system", content: systemPrompt },
                { role: "user", content: userPrompt }
            ]
        })
    });
    
    const data = await response.json();
    return data.choices[0].message.content;
}

async function main() {
    for (const model of [model1, model2]) {
        const joke = await generateJoke(model);
        console.log(`--- ${model} ---`);
        console.log("USER: Why did the programmer break up with their keyboard?");
        console.log(`AI  : ${joke}`);
    }
}

main().catch(console.error);
```

{% endcode %}
{% endtab %}
{% endtabs %}

In our example run, we received the following output:

{% code overflow="wrap" %}

```http
--- gpt-4o ---
USER: Why did the programmer break up with their keyboard?
AI  : Because it just wasn't their type!
--- MiniMax-Text-01 ---
USER: Why did the programmer break up with their keyboard?
AI  : Because it kept hitting the wrong keys!
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.aimlapi.com/capabilities/models-comparsion.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
