Skip to content

AI API

List Models

List all available models from the configured AI service.

  • Method: GET
  • Path: /v1/models

Response (200 OK)

json
{
  "object": "list",
  "data": [
    {
      "id": "gpt-4o",
      "object": "model",
      "created": 1715368132,
      "owned_by": "system"
    }
  ]
}

Example Request (cURL)

bash
curl -X GET https://api.perlica.my.id/v1/models

Example Request (JavaScript / Fetch)

javascript
async function listModels() {
  const response = await fetch("https://api.perlica.my.id/v1/models");
  const data = await response.json();
  console.log(data);
}

listModels();

Chat Completions

Create a chat completion request, which proxies to the configured AI service.

  • Method: POST
  • Path: /v1/chat/completions

Headers

  • Content-Type: application/json

Body Follows the standard Chat Completions API format. For example:

json
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}

Example Request (cURL)

bash
curl -X POST https://api.perlica.my.id/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'

Example Request (JavaScript / Fetch)

javascript
async function chatCompletion() {
  const response = await fetch("https://api.perlica.my.id/v1/chat/completions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "gpt-4o",
      messages: [{ role: "user", content: "Hello!" }]
    })
  });

  const data = await response.json();
  console.log(data);
}

chatCompletion();