VIABLE Lab API (1.2.5)

Welcome to the VIABLE Lab API!

This API provides streamlined access to powerful Large Language Models (LLMs) for research, prototyping, and educational technology development within Viable Lab and for our collaborators. Our goal is to simplify integrating diverse AI models into your projects through a unified, familiar interface.

Key Features:

  • Multiple Service Endpoints: Offers different ways to interact with LLMs, including standard OpenAI-compatible chat, easy-to-use vetted chat, and a comprehensive vetting service for detailed educational scenarios.
  • OpenAI Compatibility: The /v1/chat/completions and /v1/chat/vetting endpoints are designed for easy migration from the standard OpenAI API.
  • Curated Model Access: Access optimized models via intuitive aliases (viable-1, viable-2, viable-3) or directly request specific provider models. See Available Models.
  • Centralized Management: Benefits from features like rate limiting, improved usage logging (including detailed internal call traces), and secure API key handling.

Model Selection

We offer various models optimized for different needs:

  • viable-1: Recommended for complex evaluation and sophisticated text generation (higher cost).
  • viable-2: Efficient for common tasks like classification, summarization, and standard text completion.
  • viable-3: Balanced performance and cost with stable output, good for formatted results.
  • Direct Access: Request specific models like gpt-4o-mini, gpt-4.1-mini, gpt-4.1-nano, gpt-4.1, gpt-4o, gemini-2.0-flash directly (check availability).
  • Default: /v1/chat/completions defaults to gpt-4.1-nano if no model is specified.

(See the Models section or call /v1/models for the current list of supported IDs and aliases. For a user-friendly overview of all current and upcoming models, please visit our Model Catalog.)

Chat & Vetting Options

We provide three primary ways to generate chat responses:

  1. Standard Chat Completions (/v1/chat/completions):
    • Provides standard LLM interaction compatible with the OpenAI API.
    • Ideal for general-purpose chat or when migrating directly from OpenAI. See the endpoint description for a Quick Start guide.
  2. Chat Completions with Easy Vetting (/v1/chat/vetting):
    • Acts as a drop-in replacement for standard chat completions but adds an internal layer of content vetting based on simple guidelines.
    • Great for quickly adding basic safety or pedagogical filtering without complex configuration.
    • See the endpoint description for its Quick Start guide.
  3. Full Vetting Service (/v1/vetting/full):
    • A specialized workflow for detailed educational scenarios requiring verification against specific question contexts and answer keys.
    • Provides granular control and detailed feedback on the vetting process.
    • Use this when you need rigorous checks against revealing specific answers or concepts.

Streaming Support

Please note that streaming (stream: true) is currently NOT SUPPORTED by this router for any endpoint.

  • Rationale: The current implementation prioritizes accurate, detailed logging and complete processing for non-streaming requests, especially with the multi-step vetting logic.
  • Future Plans: Robust streaming support may be added later.

Authentication

Secure access via Bearer Token authentication (e.g., Firebase ID Token) is planned but not currently enforced. (Security Advisory: Current deployments rely on temporary, insecure Origin/Referer checks for browser requests. Proper authentication is pending.)

Platform Identification for Server-Side Requests

Standard Origin or Referer headers, which are automatically sent by browsers, are not included in direct server-to-server API calls. To ensure your platform's usage is correctly tracked and analyzed, any server-side integration must include the following custom HTTP header:

  • X-Platform-ID: A unique identifier for your application or platform.
    • Example: X-Platform-ID: my-educational-app.com

This allows our system to reliably attribute API usage to your service. Browser-based (client-side) requests will continue to be identified automatically via the Origin header and do not require this custom header.

Included Services Summary

  • Status (/): Basic API health check.
  • Model Listing (/v1/models): Lists available models and aliases.
  • Chat - Completions (/v1/chat/completions): Standard OpenAI-compatible chat.
  • Chat - VETTING (/v1/chat/vetting): Easy OpenAI-compatible chat with basic internal vetting.
  • VETTING - Full (/v1/vetting/full): Comprehensive vetting service for educational use cases.

Getting Started & Support

  • Explore the specific endpoint definitions below for detailed request/response schemas and examples.
  • Use the / endpoint to check API status.
  • Use /v1/models to discover available models and aliases.
  • Refer to the Quick Start sections within the /v1/chat/completions and /v1/chat/vetting endpoint descriptions for easy migration steps.
  • For questions or access, visit the Viable Lab website or contact us.

Status

API health and information endpoints.

Get API Status

Provides basic status information about the router service. Useful for health checks. No authentication required.

Responses

Response samples

Content type
application/json
{}

Models

Retrieve information about available models.

List Available Models

Retrieves a list of currently available models accessible through this router, including their IDs, descriptions, and ownership information. Useful for discovering capabilities and selecting appropriate models for requests. Includes aliases like viable-1, viable-2, and viable-3 as well as direct model access (e.g., gpt-4.1, gpt-4o, gemini-2.0-flash).

A more detailed and visually organized list is also available at the Model Catalog.

Responses

Response samples

Content type
application/json
{
  • "object": "list",
  • "available_models": [
    ],
  • "upcoming_models": [
    ]
}

Chat - Completions

Generate standard or vetted LLM responses based on chat history using an OpenAI-compatible format.

Create Chat Completion

Generates a standard response from an LLM based on a provided conversation history. This endpoint is designed to be compatible with the OpenAI /v1/chat/completions API format.

Quick Start (Migrating from OpenAI API): Migrating your existing OpenAI API calls to use our service is straightforward:

  1. Change the API Endpoint URL: Update the request URL from https://api.openai.com/v1/chat/completions to https://api.viablelab.org/v1/chat/completions.
  2. Remove Client-Side Auth: Crucially, remove the Authorization: Bearer YOUR_OPENAI_KEY header from your client-side request. Our API handles authentication securely on the server-side. This improves security by preventing your API key from being exposed in frontend code or network requests.
  3. Check Model: Ensure the model ID specified in your request body (e.g., {"model": "gpt-4o-mini", ...}) is available in our service. Check the current model list for supported IDs and aliases (like viable-1, viable-2, viable-3).
  4. Keep Request Body: Your existing OpenAI-compatible JSON request body (with messages, model, etc.) remains the same.

That's it! Enjoy easy migration and potentially enhanced security practices.

Authentication: (Reminder: Bearer Token authentication is planned but not currently enforced. Access currently relies on temporary Origin/Referer checks via CORS middleware for browser requests.)

Model Selection:

  • Use the model field to specify a model ID or alias (e.g., viable-3, gpt-4o-mini). See the /v1/models endpoint or the Model Catalog for available options.
  • If model is omitted, the default model (currently gpt-4.1-nano) is used.
  • Requesting an unsupported model will result in a 400 Bad Request error.

Image Input (Multimodal): For models that support image input (e.g., viable-1, gpt-4o-mini), you can provide images via URLs within the messages array. Structure the content field of a message as an array containing objects with type: 'text' and type: 'image_url' as shown in the example below. Only image_url is currently supported (not base64 data).

Streaming: Streaming (stream: true) is currently not supported. Requests with stream: true may result in an error or unexpected behavior.

Request Body schema: application/json

Request payload conforming to the OpenAI Chat Completions format.

required
Array of objects (ChatMessage) non-empty

A list of messages comprising the conversation history, ending with the latest user message.

model
string

ID of the model or alias to use (e.g., viable-3, gpt-4o-mini). Defaults apply if omitted. See /v1/models for supported models (Note: Gemini models are not supported by this endpoint).

max_tokens
integer

Maximum number of tokens to generate. Overrides router's default if lower.

temperature
number <float> [ 0 .. 2 ]
Default: 1
top_p
number <float> [ 0 .. 1 ]
Default: 1
n
integer
Default: 1

How many chat completion choices to generate. (Passed through)

(string or null) or (Array of strings or null)

Up to 4 sequences where the API will stop generating. (Passed through)

presence_penalty
number <float>
Default: 0
frequency_penalty
number <float>
Default: 0
object or object or object

An object specifying the format that the model must output. Use { "type": "json_object" } to enable JSON mode, which ensures the message the model generates is valid JSON. Note: The model needs instructions in the prompt to produce JSON.

stream
boolean
Default: false

If set to true, the response will be streamed. Currently NOT SUPPORTED by this API; setting to true will result in a 400 error.

Responses

Request samples

Content type
application/json
Example
{
  • "model": "viable-2",
  • "messages": [
    ]
}

Response samples

Content type
application/json
Example
{
  • "id": "chatcmpl-BP1zr9we9GnhROVO6W02nlAO9JYz3",
  • "object": "chat.completion",
  • "created": 1745305575,
  • "choices": [
    ],
  • "usage": {
    }
}

Create Chat Completion with Easy VETTING

Generates an LLM response based on conversation history, similar to /v1/chat/completions, but includes a simplified internal vetting layer to ensure responses adhere to basic guidelines.

Purpose: Provides an easy way to get generally safer or guided responses without needing the full configuration of the /v1/vetting/full endpoint. Ideal for quickly adding basic content filtering or adherence to simple pedagogical rules.

Interface: Designed for easy adoption, acting as a near drop-in replacement for standard chat completion requests.

Quick Start:

  • Already using https://api.viablelab.org/v1/chat/completions?
    • Simply change the request URL to https://api.viablelab.org/v1/chat/vetting.
    • Your existing request body (messages, model, etc.) will work.
    • The response format is identical to /v1/chat/completions, but includes an additional vetting_info object at the top level, showing the internal attemptCount and stopReason. The main choices[0].message.content is the vetted, ready-to-use response.
  • Migrating from OpenAI API?
    • Change the API endpoint URL to https://api.viablelab.org/v1/chat/vetting.
    • Ensure the model field in your request body specifies a model ID supported by our service (see available models).
    • That's it! You get the benefits of basic vetting with minimal changes.

Basic Vetting (Default): If you make no changes other than the URL, a default safety/guidance prompt is applied internally (e.g., "Ensure the response is helpful, harmless... guide the user, don't give direct answers to homework...").

Vetting Customization (Optional):

  • To tailor the filtering, include an optional vettingConfig object in your request body:
    • vettingConfig.systemPrompt: Provide a concise guideline string (e.g., "Do not provide code directly, only explain the concepts.", "Adapt response for a 5th-grade reading level.", "Focus answers on the subject of biology.").
    • vettingConfig.maxAttempts: Optionally adjust the internal retry limit (default is 3).
  • If vettingConfig.systemPrompt is omitted, the default guideline is used.

Image Input (Multimodal): Similar to /v1/chat/completions, you can provide image URLs in the messages.content array for models that support it. The vetting layer currently operates primarily on the text content.

Output: Returns a standard OpenAI Chat Completion response object, plus a top-level vetting_info object containing:

  • attemptCount: The number of internal vetting attempts made.
  • stopReason: Why the internal vetting loop stopped (e.g., VERIFICATION_PASSED, MAX_ATTEMPTS_REACHED).

Model Selection: Uses the model field like /v1/chat/completions. A default verification model (gpt-4o-mini) is used internally for the vetting step.

Streaming: Not supported.

Request Body schema: application/json

Request payload similar to OpenAI Chat Completions, with an optional vettingConfig for custom guidelines.

object (ChatVettingConfig)
required
Array of objects non-empty

Conversation history. System message can be included here.

model
string

ID of the chat model or alias to use (e.g., viable-3, gpt-4o-mini). Defaults apply if omitted. See /v1/models for supported models (Note: Gemini models are not supported by this endpoint).

max_tokens
integer

Maximum number of tokens to generate. Overrides router's default if lower.

temperature
number <float> [ 0 .. 2 ]
Default: 1
top_p
number <float> [ 0 .. 1 ]
Default: 1
n
integer
Default: 1

How many chat completion choices to generate. (Passed through)

(string or null) or (Array of strings or null)

Up to 4 sequences where the API will stop generating. (Passed through)

presence_penalty
number <float>
Default: 0
frequency_penalty
number <float>
Default: 0
object or object or object

An object specifying the format that the model must output. Use { "type": "json_object" } to enable JSON mode, which ensures the message the model generates is valid JSON. Note: The model needs instructions in the prompt to produce JSON.

stream
boolean
Default: false

If set to true, the response will be streamed. Currently NOT SUPPORTED by this API; setting to true will result in a 400 error.

Responses

Request samples

Content type
application/json
Example
{
  • "model": "viable-3",
  • "messages": [
    ],
  • "temperature": 0.5,
  • "vettingConfig": {
    }
}

Response samples

Content type
application/json
Example
{
  • "id": "chatcmpl-d148a3ed-d31e-445e-a320-654ccbf4f505",
  • "object": "chat.completion",
  • "created": 1745312855,
  • "model": "viable-3",
  • "choices": [
    ],
  • "usage": {
    },
  • "vetting_info": {
    },
  • "safety_signals": {
    }
}

Audio

Endpoints for generating and processing audio (Text-to-Speech, Speech-to-Text).

Create Speech

Generates audio from the input text using a Text-to-Speech (TTS) model (also known as Text to speech).

This endpoint is based on OpenAI's TTS API and currently routes requests to their service.

Use Cases:

  • Narrate a written blog post
  • Produce spoken audio in multiple languages
  • Give realtime audio output using streaming (Note: Streaming via this endpoint might depend on client handling, the API itself returns the full audio currently)

Important: OpenAI usage policies require you to provide a clear disclosure to end users that the TTS voice they are hearing is AI-generated and not a human voice.

Models: gpt-4o-mini-tts, tts-1, tts-1-hd Voices: alloy, ash, ballad, coral, echo, fable, onyx, nova, sage, shimmer, verse

Quickstart Examples:

Curl:

curl https://api.viablelab.org/v1/audio/speech \
  -H "Authorization: Bearer YOUR_VIABLE_LAB_KEY_OR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ \n    "model": "gpt-4o-mini-tts", \n    "input": "The VIABLE Lab at the University of Florida advances educational research by developing AI-powered technologies that enhance learning through data-driven insights and interdisciplinary collaboration.", \n    "voice": "alloy" \n  }' \
  --output speech.mp3

Python:

# Assuming you have a client library or use requests
import requests
import shutil

api_url = "https://api.viablelab.org/v1/audio/speech"
headers = {
    # "Authorization": "Bearer YOUR_VIABLE_LAB_KEY_OR_TOKEN", # Add if auth is implemented
    "Content-Type": "application/json",
}
data = {
    "model": "gpt-4o-mini-tts",
    "input": "The VIABLE Lab at the University of Florida advances educational research by developing AI-powered technologies that enhance learning through data-driven insights and interdisciplinary collaboration.",
    "voice": "alloy"
}

speech_file_path = "speech.mp3"

response = requests.post(api_url, headers=headers, json=data, stream=True)

if response.status_code == 200:
    with open(speech_file_path, 'wb') as f:
        response.raw.decode_content = True
        shutil.copyfileobj(response.raw, f)
    print(f"Audio saved to {speech_file_path}")
else:
    print(f"Error: {response.status_code}")
    print(response.text)

JavaScript (Node.js):

import fs from 'fs';
import path from 'path';
import fetch from 'node-fetch'; // Or your preferred fetch implementation

const api_url = 'https://api.viablelab.org/v1/audio/speech';
const headers = {
    // 'Authorization': 'Bearer YOUR_VIABLE_LAB_KEY_OR_TOKEN', // Add if auth is implemented
    'Content-Type': 'application/json',
};
const body = JSON.stringify({
    model: 'gpt-4o-mini-tts',
    input: 'Today is a wonderful day to build something people love!',
    voice: 'alloy',
});

const speechFile = path.resolve('./speech.mp3');

async function main() {
  try {
    const response = await fetch(api_url, { method: 'POST', headers: headers, body: body });

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    const buffer = await response.arrayBuffer();
    await fs.promises.writeFile(speechFile, Buffer.from(buffer));
    console.log(`Audio saved to ${speechFile}`);
  } catch (error) {
    console.error('Error fetching or saving speech:', error);
  }
}
main();

Supported Output Formats: mp3 (default), opus, aac, flac, wav, pcm.

Request Body schema: application/json

Request payload for generating speech.

input
required
string <= 4096 characters

The text to generate audio for. Maximum length: 4096 characters.

model
required
string
Enum: "tts-1" "tts-1-hd" "gpt-4o-mini-tts"

One of the available TTS models.

voice
required
string
Enum: "alloy" "ash" "ballad" "coral" "echo" "fable" "onyx" "nova" "sage" "shimmer" "verse"

The voice to use for generation.

instructions
string

(Optional) Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.

response_format
string
Default: "mp3"
Enum: "mp3" "opus" "aac" "flac" "wav" "pcm"

The format for the audio output.

speed
number <float> [ 0.25 .. 4 ]
Default: 1

The speed of the generated audio (0.25 to 4.0).

Responses

Request samples

Content type
application/json
{
  • "model": "gpt-4o-mini-tts",
  • "input": "The VIABLE Lab at the University of Florida advances educational research by developing AI-powered technologies that enhance learning through data-driven insights and interdisciplinary collaboration.",
  • "voice": "alloy"
}

Response samples

Content type
application/json
{
  • "error": {
    }
}

Create Transcription

Transcribes audio into the input language (Speech-to-Text).

(Planned / Not Yet Implemented)

This endpoint will accept audio file uploads and return the transcribed text.

Request Body schema: multipart/form-data

Audio file to transcribe and relevant parameters (e.g., model, language). Typically sent as multipart/form-data.

file
required
string <binary>

The audio file object (e.g., mp3, wav) to transcribe.

model
required
string

ID of the model to use (e.g., whisper-1).

language
string

(Optional) The ISO-639-1 language code of the input audio.

Responses

Response samples

Content type
application/json
{
  • "text": "string"
}

VETTING - Full

Generate LLM responses with a comprehensive verification layer (against question/answer keys) for educational purposes (VETTING framework).

Create Chat Response with Full VETTING Verification

Generates an LLM response with a comprehensive verification layer designed for educational contexts, checking against specific questions and answer keys.

Use Case: Intended for scenarios requiring detailed checks, like ensuring an AI tutor doesn't reveal specific answers or key concepts defined in context.items. Provides detailed feedback on verification attempts.

Modes:

  • vetting: Enables the full verification layer. Requires config.verificationModel and context.items (containing question and answerKey objects).
  • chat: Standard chat completion using this endpoint's structure but without performing verification (verification config/context ignored).

Context: Requires context.items with question and answerKey when mode='vetting'.

Output: Returns a detailed response including the final message, verification status (passed, stopReason), and details of each attempt.

Streaming: Not supported.

Request Body schema: application/json

Payload for the VETTING Service. Requires context.items with question/answer keys in 'vetting' mode.

mode
required
string
Enum: "vetting" "chat"

(Required) Operation mode: 'vetting' enables the verification layer, 'chat' provides standard chat.

required
object (VETTINGConfig)
required
object (VETTINGPrompts)

Container for system prompts. The object itself is required in the request, but the fields within are optional.

object (VETTINGContext)

Contextual information. The 'items' array is required if mode='vetting'.

required
Array of objects (ChatMessage) non-empty

(Required) Conversation history, ending with the last user message. Client should provide messages with roles 'user' and optionally previous 'assistant' messages. Do not include 'system' role messages here; use the prompts field instead.

Responses

Request samples

Content type
application/json
{
  • "mode": "vetting",
  • "config": {
    },
  • "prompts": {
    },
  • "context": {
    },
  • "messages": [
    ]
}

Response samples

Content type
application/json
{
  • "status": "success",
  • "mode": "vetting",
  • "result": {
    },
  • "verification": {
    },
  • "safety_signals": {
    },
  • "usage": {
    },
  • "metadata": {
    }
}
← Back to Developer Portal