OpenAI-Compatible

OpenAI Compatibility Guide

Seamlessly integrate Ask Sage using the standard OpenAI API format

Table of Contents
  1. What’s New?
  2. Chat Completions
    1. Request Parameters
    2. Response
    3. Example: Basic Chat Completion
    4. Example: Multi-Turn Conversation
    5. Example: Function Calling
  3. List Available Models
    1. Request Parameters
    2. Response
    3. Example
  4. How It Works
    1. Example: Making Requests
  5. Migration Guide

What’s New?


Chat Completions

Create a Chat Completion

POST https://api.asksage.ai/server/openai/v1/chat/completions

The main endpoint for conversational AI using the standard OpenAI format.

Authentication: Use a Bearer token in the Authorization header.

Request Parameters

Parameter Type Required Description
Authorization string (header) Required Bearer token: Bearer YOUR_API_KEY
model string Required The AI model to use (e.g., gpt-4.1-mini, claude-35-sonnet)
messages array Required Array of message objects with role (system/user/assistant) and content
temperature number Optional Controls randomness (0.0–2.0). Default: 1.0
max_tokens integer Optional Maximum number of tokens to generate
top_p number Optional Nucleus sampling parameter (0.0–1.0). Default: 1.0
frequency_penalty number Optional Reduces likelihood of repeating tokens (-2.0 to 2.0). Default: 0.0
presence_penalty number Optional Increases likelihood of new topics (-2.0 to 2.0). Default: 0.0
tools array Optional Array of tool/function definitions for function calling
tool_choice string Optional "none", "auto", or specific tool. Default: "auto"

Response

Status Description
200 Success Returns id, object (chat.completion), created, model, choices (with index, message, finish_reason), and usage
400 Error Invalid request format or missing required parameters
401 Error Authentication failure — invalid or missing API key

Example: Basic Chat Completion

curl -X POST 'https://api.asksage.ai/server/openai/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4.1-mini",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is Ask Sage?"}
    ]
  }'

Example: Multi-Turn Conversation

curl -X POST 'https://api.asksage.ai/server/openai/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4.1-mini",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "My name is Alice."},
      {"role": "assistant", "content": "Nice to meet you, Alice!"},
      {"role": "user", "content": "What'\''s my name?"}
    ],
    "temperature": 0.3
  }'

Example: Function Calling

Tip: Function calling enables the model to call external functions or tools to retrieve information.
curl -X POST 'https://api.asksage.ai/server/openai/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4.1-mini",
    "messages": [
      {"role": "user", "content": "What'\''s the weather like in San Francisco?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the current weather in a location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
              "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

List Available Models

List Models

GET https://api.asksage.ai/server/openai/v1/models

Retrieve a list of all available AI models in OpenAI format.

Request Parameters

Parameter Type Required Description
Authorization string (header) Required Bearer token: Bearer YOUR_API_KEY

Response

Status Description
200 Success Returns object: "list" and data array of model objects with id, object, created, owned_by
401 Error Authentication failure

Example

curl -X GET 'https://api.asksage.ai/server/openai/v1/models' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Accept: application/json'

How It Works

Same Pattern as OpenAI

Ask Sage's openai/v1/* endpoints follow the exact same API specification as OpenAI, making integration seamless.

You can use Ask Sage's API with the same request/response patterns you're familiar with from OpenAI. Simply point your requests to Ask Sage's base URL with Bearer token authentication.

Key Difference: Instead of using OpenAI's base URL (https://api.openai.com/v1), use Ask Sage's base URL (https://api.asksage.ai/server/openai/v1).

Example: Making Requests

# Ask Sage API (OpenAI-compatible format)
curl -X POST 'https://api.asksage.ai/server/openai/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4.1-mini",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'
Same Patterns: Use the same request structure, parameters, and response formats you're already familiar with from OpenAI.

Migration Guide

Key Benefits

Easy Migration: Minimal code changes to switch from OpenAI to Ask Sage.
Familiar Patterns: Use the same API patterns and structure as OpenAI.

Important Note: Base URLs may vary depending on your environment. For assistance, please contact us at support@asksage.ai.

Back to top

Copyright © 2026 Ask Sage Inc. All Rights Reserved. Ask Sage is a BigBear.ai company.