SECRY AI API Documentation

A comprehensive guide to integrating your APP to our powerful SECRY AI REST API.

BASE URL https://api-ai2.secry.me/v1
RATE LIMIT 50-60 RPM (Depends on Traffic)
PRICE Rp 120k/month, Unlimited Token
VISION SUPPORT All models: Auto OCR enabled (supports vision/image input)

Available Models

Here is a complete list of AI models you can use through our API, organized by their creators. Choose the model that best fits your application's needs.

Meta

meta-llama/Meta-Llama-3.1-8B-Instruct-fast
meta-llama/Meta-Llama-3.1-8B-Instruct
meta-llama/Llama-Guard-3-8B
meta-llama/Llama-3.3-70B-Instruct
meta-llama/Llama-3.3-70B-Instruct-fast

Google

gemma-4-31b-it
gemma-4-26b-a4b-it
gemma-3-27b-it
gemma-3-12b-it

Alibaba Cloud (Qwen)

Qwen/Qwen2.5-Coder-7B-fast
Qwen/Qwen3-235B-A22B-Instruct-2507
Qwen/Qwen3-235B-A22B-Thinking-2507
Qwen/Qwen3-32B
Qwen/Qwen3-32B-fast
Qwen/Qwen3-30B-A3B-Thinking-2507
Qwen/Qwen3-30B-A3B-Instruct-2507
Qwen/Qwen3-Coder-30B-A3B-Instruct
Qwen/Qwen3-Coder-480B-A35B-Instruct
Qwen/Qwen3-Next-80B-A3B-Thinking

DeepSeek AI

deepseek-ai/DeepSeek-V3.1 alias v3.2 (non-thinking)
deepseek-ai/DeepSeek-V3.2 alias v3.2 (thinking)

NVIDIA

nvidia/Llama-3_1-Nemotron-Ultra-253B-v1
nvidia/Nemotron-Nano-V2-12b
nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B

OpenAI

openai/gpt-oss-120b
openai/gpt-oss-20b

Prime Intellect

PrimeIntellect/INTELLECT-3

Nous Research

NousResearch/Hermes-4-70B
NousResearch/Hermes-4-405B

Moonshot AI

moonshotai/Kimi-K2.5
moonshotai/Kimi-K2-Thinking

Zhipu AI

zai-org/GLM-5
zai-org/GLM-4.7-FP8 quantized

MiniMax AI

MiniMaxAI/MiniMax-M2.5Temp Maintenance
MiniMaxAI/MiniMax-M2.7

Embedding Models

BAAI/bge-en-icl
BAAI/bge-multilingual-gemma2
intfloat/e5-mistral-7b-instruct
Qwen/Qwen3-Embedding-8B

Multimodal (Vision-Language) Models

Qwen/Qwen2.5-VL-72B-Instruct

Image Generation Models All Models Deprecated

black-forest-labs/flux-dev
black-forest-labs/flux-schnell

1. Authentication

All requests to the API require authentication using your API key. Include the API key in the Authorization header with the following format:

Authorization: Bearer YOUR_API_KEY

Replace YOUR_API_KEY with your unique API key.

2. Endpoints

POST

2.1 Chat Completions

/v1/chat/completions

Generates a chat response based on a series of input messages.

Request Body (JSON):

{
  "model": "meta-llama/Meta-Llama-3.1-405B-Instruct",
  "messages": [
    {"role": "system", "content": "You are a helpful AI assistant."},
    {"role": "user", "content": "Tell me a short joke!"}
  ],
  "max_tokens": 50,
  "temperature": 0.7,
  "stream": false
}

Example Response (JSON):

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1743381000,
  "model": "meta-llama/Meta-Llama-3.1-405B-Instruct",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Why did the chicken cross the road? To get to the other side!"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 15,
    "total_tokens": 40
  }
}

Example Request (cURL):

curl -X POST "https://api-ai2.secry.me/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    --data-raw '{
        "model": "meta-llama/Meta-Llama-3.1-405B-Instruct",
        "messages": [
            {
                "role": "system",
                "content": "You are ReyAI from REY Assistant"
            },
            {
                "role": "user",
                "content": "Who are you, what is your model, and what company are you from"
            }
        ],
        "max_tokens": 150,
        "temperature": 0.7,
        "top_p": 0.9,
        "stream": false
    }' --insecure
GET

2.2 List Models

/v1/models

Retrieves a list of AI models currently available for use.

Example Response (JSON):

{
  "object": "list",
  "data": [
    {
      "id": "meta-llama/Meta-Llama-3.1-405B-Instruct",
      "object": "model",
      "created": 1740000000,
      "owned_by": "SECRY AI"
    },
    {
      "id": "meta-llama/Meta-Llama-3.1-70B-Instruct",
      "object": "model",
      "created": 1740000001,
      "owned_by": "SECRY AI"
    }
    // ... other models
  ]
}

Example Request (cURL):

curl -X GET "https://api-ai2.secry.me/v1/models" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    --insecure

3. Files Store and Retrieval

POST

3.1 Upload File

/v1/files

Upload a file that contains data to be used across various endpoints/features.

Request Body (multipart/form-data):

  • purpose: String (required) - The intended purpose of the uploaded file (e.g., "batch").
  • file: File (required) - The file to be uploaded.

Example Request (cURL):

curl https://api-ai2.secry.me/v1/files \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F purpose="batch" \
  -F file="@batch-requests.jsonl"

Example Response (JSON):

{
  "id": "file-abc123xyz",
  "object": "file",
  "bytes": 123456,
  "created_at": 1730723658,
  "filename": "batch-requests.jsonl",
  "purpose": "batch"
}
GET

3.2 Get File Info

/v1/files/{file_id}

Retrieves detailed information about a specific file by its ID.

Example Request (cURL):

curl https://api-ai2.secry.me/v1/files/file-abc123xyz \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response (JSON):

{
  "id": "file-abc123xyz",
  "object": "file",
  "bytes": 123456,
  "created_at": 1730723658,
  "filename": "batch-requests.jsonl",
  "purpose": "batch"
}
GET

3.3 Get File Content

/v1/files/{file_id}/content

Downloads the content of a specific file by its ID.

Example Request (cURL):

# Save the content to a file named file-content.jsonl
curl https://api-ai2.secry.me/v1/files/file-abc123xyz/content \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o file-content.jsonl
GET

3.4 List Files

/v1/files

Returns a list of files that have been uploaded by the user.

Example Request (cURL):

curl https://api-ai2.secry.me/v1/files \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response (JSON):

{
  "object": "list",
  "data": [
    {
      "id": "file-abc123xyz",
      "object": "file",
      "bytes": 123456,
      "created_at": 1730723658,
      "filename": "batch-requests.jsonl",
      "purpose": "batch"
    },
    {
      "id": "file-def456uvw",
      "object": "file",
      "bytes": 7890,
      "created_at": 1731493853,
      "filename": "another-file.txt",
      "purpose": "assistants"
    }
    // ... other files
  ]
}
DELETE

3.5 Delete a File

/v1/files/{file_id}

Permanently deletes a file by its ID.

Example Request (cURL):

curl https://api-ai2.secry.me/v1/files/file-abc123xyz \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -X DELETE

Example Response (JSON):

{
  "id": "file-abc123xyz",
  "object": "file",
  "deleted": true
}

4. Image Generation

POST

4.1 Create Image

/v1/images/generations

Creates a new image based on a text description (prompt).

Request Body (JSON):

{
  "model": "stability-ai/sdxl",
  "prompt": "A photorealistic elephant playing chess in the desert at sunset",
  "response_format": "b64_json",
  "response_extension": "webp",
  "width": 1024,
  "height": 1024,
  "num_inference_steps": 35,
  "seed": 12345,
  "negative_prompt": "cartoon, drawing, sketch, low quality, blurry"
}

Example Response (JSON):

{
  "created": 1743381100,
  "data": [
    {
      "b64_json": "UklGRl... (base64 encoded image data) ...",
      "revised_prompt": "A photorealistic elephant is playing chess in the desert during a beautiful sunset."
    }
  ],
  "id": "text2img-0941c39c-..."
}

Example Request (cURL):

curl https://api-ai2.secry.me/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "stability-ai/sdxl",
    "prompt": "An elephant in a desert playing chess",
    "response_format": "b64_json",
    "response_extension": "webp",
    "width": 512,
    "height": 512,
    "num_inference_steps": 30,
    "seed": -1,
    "negative_prompt": "Giraffes, night sky, cartoonish"
  }'

5. Function Calling

The SECRY AI API supports Function Calling, allowing you to define a set of tools or functions that the AI model can use. Based on the conversation context, the model can intelligently decide when to suggest calling a specific function to get external information or perform an action.

It's important to note that the API does not execute these functions directly. Instead, it generates tool call instructions in a JSON format compatible with the OpenAI standard, containing the function name and suggested arguments.

After receiving a tool call suggestion from the API, your application is responsible for executing the corresponding function with the provided arguments. The result of this execution can then be sent back to the model in a subsequent API request to continue the conversation dynamically.

Function Calling Workflow

  1. Define Tools: Provide a list of available tools (functions) to the model when making a request. Each tool is described using a JSON schema that defines its name, description, and input parameters.
  2. User & Model Interaction: Send the conversation (messages) and the list of tools to the API. The model will analyze the conversation and determine if it needs to use one of the tools to respond.
  3. Model Response: The model will respond with either a regular message or a tool_calls object containing instructions to call one or more functions, complete with suggested arguments in JSON format.
  4. Execute & Iterate: If the response contains tool_calls, your application executes the requested function(s). Send the execution result back to the API as a message with the role tool, along with the corresponding tool_call_id, to continue the conversation.

Example Code (Python)


import json
import os
from openai import OpenAI
from pydantic import BaseModel, Field
from typing import Literal

# Make sure you have set the YOUR_API_KEY environment variable
# or replace os.getenv('YOUR_API_KEY') with your API key string
client = OpenAI(
    base_url="https://api-ai2.secry.me/v1/",
    api_key=os.getenv('YOUR_API_KEY')
)
model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct-fast"

# 1. Define the function parameter schema using Pydantic
class GetCurrentWeatherParams(BaseModel):
    city: str = Field(..., description="The name of the city, e.g., 'San Francisco'")
    state: str | None = Field(None, description="The state or province abbreviation (optional)")
    unit: Literal['celsius', 'fahrenheit'] = Field(..., description="The unit of temperature")

# 2. Define the tool available to the model
tools = [{
    "type": "function",
    "function": {
        "name": "get_current_weather",
        "description": "Get the current weather information for a specific location.",
        "parameters": GetCurrentWeatherParams.model_json_schema() # Use the Pydantic schema
    }
}]

# 3. Start the conversation
messages = [
    {"role": "system", "content": "You are a weather assistant."},
    {"role": "user", "content": "What's the temperature in Bandung right now in Celsius?"}
]

print("--- Request to API ---")
chat_completion = client.chat.completions.create(
    messages=messages,
    model=model_id,
    tools=tools,
    tool_choice="auto" # Let the model choose if a tool is needed
)

response_message = chat_completion.choices[0].message
messages.append(response_message) # Add AI response to history

print("\n--- Response from API ---")
print(response_message)

# 4. Check if the model requested a tool call
if response_message.tool_calls:
    print("\n--- Model requested a Tool Call ---")
    
    # Define the actual Python function to be called
    def get_current_weather(city: str, state: str | None, unit: str):
        """Dummy function to get the weather"""
        print(f"Calling function get_current_weather(city='{city}', state='{state}', unit='{unit}')")
        # In a real application, you would call a weather API here
        if city.lower() == "bandung":
            temp = 22 if unit == "celsius" else 72
            return json.dumps({"city": city, "temperature": temp, "unit": unit, "condition": "Cloudy"})
        else:
            return json.dumps({"error": "City not found"})

    available_tools = {"get_current_weather": get_current_weather}

    # Execute each requested tool call
    for tool_call in response_message.tool_calls:
        function_name = tool_call.function.name
        function_to_call = available_tools.get(function_name)
        
        if function_to_call:
            function_args = json.loads(tool_call.function.arguments)
            function_response = function_to_call(**function_args)
            
            # Add the execution result to the message history
            messages.append({
                "role": "tool",
                "tool_call_id": tool_call.id,
                "name": function_name,
                "content": function_response,
            })

    print("\n--- Request to API (after tool execution) ---")
    # Send the message history (including tool result) back to the API
    second_response = client.chat.completions.create(
        model=model_id,
        messages=messages,
    )
    print("\n--- Final Response from API ---")
    print(second_response.choices[0].message.content)

else:
    print("\n--- Model responded without a Tool Call ---")
    print(response_message.content)

Example Code (JavaScript - Node.js)


import OpenAI from 'openai';
import { z } from 'zod'; // Requires: npm install zod
import { zodToJsonSchema } from 'zod-to-json-schema'; // Requires: npm install zod-to-json-schema

// Replace with your API key or use an environment variable
const apiKey = process.env.YOUR_API_KEY || 'YOUR_API_KEY';
const client = new OpenAI({
  baseURL: "https://api-ai2.secry.me/v1/",
  apiKey: apiKey,
});
const modelId = "meta-llama/Meta-Llama-3.1-8B-Instruct-fast";

// 1. Define the function parameter schema using Zod
const WeatherParamsSchema = z.object({
  city: z.string().describe("The name of the city, e.g., 'San Francisco'"),
  state: z.string().optional().describe("The state or province abbreviation (optional)"),
  unit: z.enum(["celsius", "fahrenheit"]).describe("The unit of temperature"),
});

// Convert the Zod schema to a JSON Schema
const weatherJsonSchema = zodToJsonSchema(WeatherParamsSchema, "WeatherParamsSchema");

// 2. Define the available tool
const tools = [
  {
    type: "function",
    function: {
      name: "get_current_weather",
      description: "Get the current weather information for a specific location.",
      parameters: weatherJsonSchema.definitions.WeatherParamsSchema,
    },
  }
];

// Dummy function to simulate the tool call
async function get_current_weather({ city, state, unit }) {
  console.log(`Calling function get_current_weather(city='${city}', state='${state}', unit='${unit}')`);
  // In a real app, call a weather API here
  if (city.toLowerCase() === "bandung") {
    const temp = unit === "celsius" ? 22 : 72;
    return JSON.stringify({ city, temperature: temp, unit, condition: "Cloudy" });
  } else {
    return JSON.stringify({ error: "City not found" });
  }
}

const availableTools = {
  get_current_weather: get_current_weather,
};

async function runConversation() {
  // 3. Start the conversation
  const messages = [
    { role: "system", content: "You are a weather assistant." },
    { role: "user", content: "What's the temperature in Bandung right now in Celsius?" }
  ];

  console.log("--- Request to API ---");
  let response = await client.chat.completions.create({
    model: modelId,
    messages: messages,
    tools: tools,
    tool_choice: "auto",
  });

  let responseMessage = response.choices[0].message;
  messages.push(responseMessage);

  console.log("\n--- Response from API ---");
  console.log(responseMessage);

  // 4. Check for and execute tool calls
  if (responseMessage.tool_calls) {
    console.log("\n--- Model requested a Tool Call ---");
    for (const toolCall of responseMessage.tool_calls) {
      const functionName = toolCall.function.name;
      const functionToCall = availableTools[functionName];
      const functionArgs = JSON.parse(toolCall.function.arguments);
      const functionResponse = await functionToCall(functionArgs);
      
      messages.push({
        tool_call_id: toolCall.id,
        role: "tool",
        name: functionName,
        content: functionResponse,
      });
    }

    console.log("\n--- Request to API (after tool execution) ---");
    const secondResponse = await client.chat.completions.create({
      model: modelId,
      messages: messages,
    });
    console.log("\n--- Final Response from API ---");
    console.log(secondResponse.choices[0].message.content);
  } else {
     console.log("\n--- Model responded without a Tool Call ---");
     console.log(responseMessage.content);
  }
}

runConversation().catch(console.error);

Example Response with a Tool Call

This is an example of what the message history might look like after the model requests a tool call and you send back the result.

[
  {
    "role": "system",
    "content": "You are a weather assistant."
  },
  {
    "role": "user",
    "content": "What's the temperature in Bandung right now in Celsius?"
  },
  {
    "role": "assistant",
    "content": null,
    "tool_calls": [
      {
        "id": "call_abc123",
        "type": "function",
        "function": {
          "name": "get_current_weather",
          "arguments": "{\\"city\\": \\"Bandung\\", \\"unit\\": \\"celsius\\"}"
        }
      }
    ]
  },
  {
    "role": "tool",
    "tool_call_id": "call_abc123",
    "name": "get_current_weather",
    "content": "{\\"city\\": \\"Bandung\\", \\"temperature\\": 22, \\"unit\\": \\"celsius\\", \\"condition\\": \\"Cloudy\\"}"
  },
  {
    "role": "assistant",
    "content": "The current temperature in Bandung is 22 degrees Celsius with cloudy conditions."
  }
]

Limitations

The tool_choice parameter controls how the model selects a function:

  • "auto" (default): The model decides whether to call a function and which function to call.
  • "none": The model will not call any function.
  • {"type": "function", "function": {"name": "specific_function_name"}}: Forces the model to call that specific function.

6. Error Handling

If an error occurs while processing your request, the API will return a response with an appropriate HTTP status code (e.g., 400, 401, 429, 500) and a JSON body containing error details.

Example Error Response (JSON):

{
  "error": {
    "message": "Incorrect API key provided. Contact Admin/Owner.",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}

Be sure to handle these status codes and error messages in your application to provide a better user experience.

7. Rate Limits

This API has rate limits to ensure fair usage and service stability. The current limit is 50-60 Requests Per Minute (RPM) per user.

If you exceed this limit, you will receive an error response with a 429 Too Many Requests status code. It is recommended to implement a retry mechanism with exponential backoff on your client side.

8. Support

If you encounter technical issues, have questions about using the API, or need other assistance, please do not hesitate to contact our support team via email:

[email protected]

Important Note: Always ensure you are using a stable version of the API and check this documentation periodically for updates to endpoints, parameters, or available models.