OpenAI Compatibility

Overview

OpenAI Compatibility provides functionality to interact with the View Assistant platform using OpenAI-compatible API endpoints. It enables seamless integration with existing OpenAI client libraries and applications by providing compatible chat completion and model listing endpoints.

OpenAI compatibility operations are managed via the Assistant API at [http|https]://[hostname]:[port]/v1.0/tenants/[tenant-guid]/assistant/openai and support OpenAI-compatible chat completions and model listing for easy integration with existing OpenAI-based applications.

API Endpoints

OpenAI compatibility operations are managed via the Assistant server API at:

  • Chat Completions: [http|https]://[hostname]:[port]/v1.0/tenants/[tenant-guid]/assistant/openai/chat/completions
  • Models: [http|https]://[hostname]:[port]/v1.0/tenants/[tenant-guid]/assistant/openai/models

Supported HTTP Methods: POST, GET

Important: All OpenAI compatibility operations require appropriate authentication tokens.

Chat Completion

Creates a chat completion compatible with the OpenAI endpoint using POST /v1.0/tenants/[tenant-guid]/assistant/openai/chat/completions.

Request Body

{
  "model": "{{config-guid}}",
  "messages": [
    {
      "role": "user",
      "content": "What is RAG?"
    }
  ],
  "stream": true
}
curl --location 'http://localhosts:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/openai/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
  "model": "{{config-guid}}",
  "messages": [
    {
      "role": "user",
      "content": "What is RAG?"
    }
  ],
  "stream": true
}'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "00000000-0000-0000-0000-000000000000", //tenant Id
  "default" //access key
);

const chatCompletion = async () => {
  try {
    const response = await api.OpenAICompatibility.chatCompletion({
        "model": "{{config-guid}}",
        "messages": [
          {
            "role": "user",
            "content": "What is RAG?"
          }
        ],
        "stream": true
    });
    console.log(response, "Chat completion completed successfully");
  } catch (err) {
    console.log("Error creating chat completion:", err);
  }
};

chatCompletion();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost",
    tenant_guid="00000000-0000-0000-0000-000000000000",
    service_ports={Service.DEFAULT: 8000},
)

def chatCompletion():
    response = assistant.OpenAICompatibility.chat_completion(
        request={
            "Messages": [
                {"role": "system", "content": "You are a helpful assistant."},
                {"role": "user", "content": "Hello, how are you?"}
            ],
            "ModelName": "gpt-4o-mini",
            "Temperature": 0.7,
            "TopP": 0.95,
            "MaxTokens": 1000,
            "GenerationProvider": "openai",
            "GenerationApiKey": "API_KEY",
            "Stream": False
        }
    )
    print("Chat Completion Response:")
    print(response)

chatCompletion()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("00000000-0000-0000-0000-000000000000"), 
                                            "default", 
                                            "http://localhost:8000/");

var response = await sdk.OpenAICompatibility.ChatCompletion(new {
    Messages = new[] {
        new { role = "system", content = "You are a helpful assistant." },
        new { role = "user", content = "Hello, how are you?" }
    },
    ModelName = "gpt-4o-mini",
    Temperature = 0.7,
    TopP = 0.95,
    MaxTokens = 1000,
    GenerationProvider = "openai",
    GenerationApiKey = "API_KEY",
    Stream = false
});

List Models

Lists available models compatible with the OpenAI API using GET /v1.0/tenants/[tenant-guid]/assistant/openai/models.

curl --location 'http://localhost:8000/v1.0/tenants/00000000-0000-0000-0000-000000000000/assistant/openai/models' \
--header 'Authorization: ••••••'
import { ViewAssistantSdk } from "view-sdk";

const api = new ViewAssistantSdk(
  "http://localhost:8000/", //endpoint
  "00000000-0000-0000-0000-000000000000", //tenant Id
  "default" //access key
);

const listModels = async () => {
  try {
    const response = await api.OpenAICompatibility.listModels();
    console.log(response, "Models listed successfully");
  } catch (err) {
    console.log("Error listing models:", err);
  }
};

listModels();
import view_sdk
from view_sdk import assistant
from view_sdk.sdk_configuration import Service

sdk = view_sdk.configure(
    access_key="default",
    base_url="localhost",
    tenant_guid="00000000-0000-0000-0000-000000000000",
    service_ports={Service.DEFAULT: 8000},
)

def listModels():
    response = assistant.OpenAICompatibility.list_models()
    print("Available Models:")
    print(response)

listModels()
using View.Sdk;
using View.Sdk.Assistant;

ViewAssistantSdk sdk = new ViewAssistantSdk(Guid.Parse("00000000-0000-0000-0000-000000000000"), 
                                            "default", 
                                            "http://localhost:8000/");

var response = await sdk.OpenAICompatibility.ListModels();