> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Chat Compare

POST https://api.meshapi.ai/v1/chat/compare
Content-Type: application/json

Reference: https://developers.meshapi.ai/api-reference/mesh-api/chat/compare-v-1-chat-compare-post

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/chat/compare:
    post:
      operationId: compare-v-1-chat-compare-post
      summary: Chat Compare
      tags:
        - subpackage_chat
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompareRequest'
servers:
  - url: https://api.meshapi.ai
components:
  schemas:
    MessageRole:
      type: string
      enum:
        - system
        - user
        - assistant
        - tool
      title: MessageRole
    ContentPartType:
      type: string
      enum:
        - text
        - image_url
        - input_audio
      title: ContentPartType
    ImageUrlDetail:
      type: string
      enum:
        - auto
        - low
        - high
      default: auto
      title: ImageUrlDetail
    ImageUrl:
      type: object
      properties:
        url:
          type: string
        detail:
          $ref: '#/components/schemas/ImageUrlDetail'
      required:
        - url
      title: ImageUrl
    InputAudioFormat:
      type: string
      enum:
        - wav
        - mp3
        - aiff
        - aac
        - ogg
        - flac
        - m4a
        - pcm16
        - pcm24
      title: InputAudioFormat
    InputAudio:
      type: object
      properties:
        data:
          type:
            - string
            - 'null'
        uri:
          type:
            - string
            - 'null'
        format:
          $ref: '#/components/schemas/InputAudioFormat'
      required:
        - format
      title: InputAudio
    ContentPart:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ContentPartType'
        text:
          type:
            - string
            - 'null'
        image_url:
          oneOf:
            - $ref: '#/components/schemas/ImageUrl'
            - type: 'null'
        input_audio:
          oneOf:
            - $ref: '#/components/schemas/InputAudio'
            - type: 'null'
      required:
        - type
      title: ContentPart
    MessageContent1:
      type: array
      items:
        $ref: '#/components/schemas/ContentPart'
      title: MessageContent1
    MessageContent:
      oneOf:
        - type: string
        - $ref: '#/components/schemas/MessageContent1'
      title: MessageContent
    ToolCall:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - function
        function:
          type: object
          additionalProperties:
            description: Any type
      required:
        - id
        - function
      title: ToolCall
    Message:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/MessageRole'
        content:
          oneOf:
            - $ref: '#/components/schemas/MessageContent'
            - type: 'null'
        name:
          type:
            - string
            - 'null'
        tool_call_id:
          type:
            - string
            - 'null'
        tool_calls:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ToolCall'
      required:
        - role
      title: Message
    ModelOverride:
      type: object
      properties:
        model:
          type: string
        temperature:
          type:
            - number
            - 'null'
          format: double
        max_tokens:
          type:
            - integer
            - 'null'
        system_prompt:
          type:
            - string
            - 'null'
      required:
        - model
      description: >-
        Per-model parameter overrides applied on top of the request-level
        defaults.
      title: ModelOverride
    CompareRequest:
      type: object
      properties:
        models:
          type: array
          items:
            type: string
        messages:
          type: array
          items:
            $ref: '#/components/schemas/Message'
        model_overrides:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ModelOverride'
        comparison_model:
          type:
            - string
            - 'null'
        comparison_instructions:
          type:
            - string
            - 'null'
        temperature:
          type:
            - number
            - 'null'
          format: double
        max_tokens:
          type:
            - integer
            - 'null'
        stream:
          type: boolean
          default: false
        template:
          type:
            - string
            - 'null'
        variables:
          type:
            - object
            - 'null'
          additionalProperties:
            type: string
        skip_comparison:
          type: boolean
          default: false
      required:
        - models
        - messages
      title: CompareRequest
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python
import requests

url = "https://api.meshapi.ai/v1/chat/compare"

payload = {
    "models": ["gpt-4o-mini", "gpt-3.5-turbo"],
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant that compares responses from different AI models."
        },
        {
            "role": "user",
            "content": "Explain the benefits of renewable energy."
        }
    ],
    "comparison_model": "gpt-4o",
    "comparison_instructions": "Compare the responses based on accuracy, clarity, and completeness.",
    "temperature": 0.7,
    "max_tokens": 500,
    "stream": False,
    "skip_comparison": False
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.meshapi.ai/v1/chat/compare';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"models":["gpt-4o-mini","gpt-3.5-turbo"],"messages":[{"role":"system","content":"You are a helpful assistant that compares responses from different AI models."},{"role":"user","content":"Explain the benefits of renewable energy."}],"comparison_model":"gpt-4o","comparison_instructions":"Compare the responses based on accuracy, clarity, and completeness.","temperature":0.7,"max_tokens":500,"stream":false,"skip_comparison":false}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.meshapi.ai/v1/chat/compare"

	payload := strings.NewReader("{\n  \"models\": [\n    \"gpt-4o-mini\",\n    \"gpt-3.5-turbo\"\n  ],\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a helpful assistant that compares responses from different AI models.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain the benefits of renewable energy.\"\n    }\n  ],\n  \"comparison_model\": \"gpt-4o\",\n  \"comparison_instructions\": \"Compare the responses based on accuracy, clarity, and completeness.\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 500,\n  \"stream\": false,\n  \"skip_comparison\": false\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/chat/compare")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"models\": [\n    \"gpt-4o-mini\",\n    \"gpt-3.5-turbo\"\n  ],\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a helpful assistant that compares responses from different AI models.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain the benefits of renewable energy.\"\n    }\n  ],\n  \"comparison_model\": \"gpt-4o\",\n  \"comparison_instructions\": \"Compare the responses based on accuracy, clarity, and completeness.\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 500,\n  \"stream\": false,\n  \"skip_comparison\": false\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/chat/compare")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"models\": [\n    \"gpt-4o-mini\",\n    \"gpt-3.5-turbo\"\n  ],\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a helpful assistant that compares responses from different AI models.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain the benefits of renewable energy.\"\n    }\n  ],\n  \"comparison_model\": \"gpt-4o\",\n  \"comparison_instructions\": \"Compare the responses based on accuracy, clarity, and completeness.\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 500,\n  \"stream\": false,\n  \"skip_comparison\": false\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/chat/compare', [
  'body' => '{
  "models": [
    "gpt-4o-mini",
    "gpt-3.5-turbo"
  ],
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant that compares responses from different AI models."
    },
    {
      "role": "user",
      "content": "Explain the benefits of renewable energy."
    }
  ],
  "comparison_model": "gpt-4o",
  "comparison_instructions": "Compare the responses based on accuracy, clarity, and completeness.",
  "temperature": 0.7,
  "max_tokens": 500,
  "stream": false,
  "skip_comparison": false
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/chat/compare");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"models\": [\n    \"gpt-4o-mini\",\n    \"gpt-3.5-turbo\"\n  ],\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a helpful assistant that compares responses from different AI models.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Explain the benefits of renewable energy.\"\n    }\n  ],\n  \"comparison_model\": \"gpt-4o\",\n  \"comparison_instructions\": \"Compare the responses based on accuracy, clarity, and completeness.\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 500,\n  \"stream\": false,\n  \"skip_comparison\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "models": ["gpt-4o-mini", "gpt-3.5-turbo"],
  "messages": [
    [
      "role": "system",
      "content": "You are a helpful assistant that compares responses from different AI models."
    ],
    [
      "role": "user",
      "content": "Explain the benefits of renewable energy."
    ]
  ],
  "comparison_model": "gpt-4o",
  "comparison_instructions": "Compare the responses based on accuracy, clarity, and completeness.",
  "temperature": 0.7,
  "max_tokens": 500,
  "stream": false,
  "skip_comparison": false
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/chat/compare")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```