Skip to content

QubridAI-Inc/qubrid-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qubrid-examples

100+ OSS models with one OpenAI-compatible API.

Platform API License Examples

A focused set of OpenAI-compatible API examples for Qubrid AI. Use the same OpenAI client patterns and point them at https://platform.qubrid.com/v1 to access models like DeepSeek, Qwen, Llama, Mistral, Kimi and more.

Quickstart

  1. Export your Qubrid key:
export QUBRID_API_KEY="your_api_key_here"
  1. Use OpenAI-compatible clients with the Qubrid base URL:

Examples (API code)

Python example

from openai import OpenAI

client = OpenAI(
    base_url="https://platform.qubrid.com/v1",
    api_key="QUBRID_API_KEY",
)

stream = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4-Flash",
    messages=[
        {"role": "user", "content": "Explain quantum computing in simple terms"}
    ],
    max_tokens=393216,
    temperature=1,
    top_p=1,
    stream=True,
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

print("\n")

JavaScript example

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://platform.qubrid.com/v1',
  apiKey: 'QUBRID_API_KEY',
});

const stream = await client.chat.completions.create({
  model: 'deepseek-ai/DeepSeek-V4-Flash',
  messages: [
    { role: 'user', content: 'Explain quantum computing in simple terms' }
  ],
  max_tokens: 393216,
  temperature: 1,
  top_p: 1,
  stream: true,
});

for await (const chunk of stream) {
  if (chunk.choices[0]?.delta?.content) {
    process.stdout.write(chunk.choices[0].delta.content);
  }
}

console.log('\n');

Go example

package main

import (
  "bytes"
  "encoding/json"
  "net/http"
)

func main() {
  url := "https://platform.qubrid.com/v1/chat/completions"

  payload := map[string]interface{}{
    "model": "deepseek-ai/DeepSeek-V4-Flash",
    "messages": []map[string]string{
      {"role": "user", "content": "Explain quantum computing in simple terms"},
    },
    "temperature": 1,
    "max_tokens": 393216,
    "stream": true,
    "top_p": 1,
  }

  jsonData, _ := json.Marshal(payload)
  req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
  req.Header.Set("Authorization", "Bearer QUBRID_API_KEY")
  req.Header.Set("Content-Type", "application/json")

  client := &http.Client{}
  _, _ = client.Do(req)
}

curl example

curl -X POST "https://platform.qubrid.com/v1/chat/completions" \
  -H "Authorization: Bearer QUBRID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "deepseek-ai/DeepSeek-V4-Flash",
  "messages": [
    {"role": "user", "content": "Explain quantum computing in simple terms"}
  ],
  "temperature": 1,
  "max_tokens": 393216,
  "stream": true,
  "top_p": 1
}'
  1. Run an example in python/, javascript/, go/, or curl/.

  2. Swap model for the OSS model you want to use.

Installation

Python

pip install openai

JavaScript / TypeScript

npm install openai

Go

go get github.com/sashabaranov/go-openai

curl

curl is available on most systems and works with the HTTP examples.

Repository structure

qubrid-examples/
│
├── chat/
│   ├── python/
│   ├── javascript/
│   ├── go/
│   └── curl/
│
├── vision/
│   ├── python/
│   ├── javascript/
│   └── curl/
│
├── voice/
│   ├── text-to-speech/
│   └── speech-to-text/
│
├── ocr/
│   ├── python/
│   └── curl/
│
├── embeddings/
│
├── README.md
├── LICENSE
└── .gitignore

Supported models

Qubrid delivers 100+ open-source and commercial models through a single OpenAI-compatible API. Example supported models include:

  • deepseek-ai/DeepSeek-V4-Flash
  • deepseek-ai/DeepSeek-V4-Pro
  • deepseek-ai/DeepSeek-V3
  • deepseek-ai/DeepSeek-R1-0528
  • qwen/qwen3-Plus
  • qwen/qwen3-Flash
  • qwen/qwen3-Max
  • qwen/qwen3-VL-Plus
  • qwen/qwen3-VL-Flash
  • qwen/qwen3-Coder-Plus
  • qwen/qwen3-Coder-Flash
  • qwen/qwen3-Coder-Next
  • qwen/qwen3-Next
  • mistralai/Mistral-7B-Instruct-v0.3
  • moonshotai/Kimi-K2.6
  • moonshotai/Kimi-K2-Thinking
  • moonshotai/Kimi-K2-Instruct
  • moonshotai/Kimi-K2.5
  • nvidia/NVIDIA-Nemotron-3-Super-120B-A12B
  • nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16
  • google/gemini-3.1-pro-preview
  • google/gemini-3-flash-preview
  • google/gemini-2.5-pro
  • google/gemini-2.5-flash
  • anthropic/claude-opus-4-7
  • anthropic/claude-opus-4-6
  • anthropic/claude-opus-4-5
  • anthropic/claude-sonnet-4-6
  • anthropic/claude-haiku-4-5-20251001
  • openai/gpt-4o
  • openai/gpt-4o-mini
  • openai/gpt-4.1
  • openai/gpt-5.4
  • openai/gpt-5.4-mini
  • openai/gpt-5.4-nano
  • meta-llama/Llama-3.3-70B-Instruct
  • microsoft/Fara-7B
  • tencent/HunyuanOCR
  • zai-org/GLM-4.7
  • zai-org/GLM-5
  • miniMaxAI/MiniMax-M2.5

Replace the model field to target any compatible OSS model supported by Qubrid.

Examples index

This repository contains ready-to-run examples organized by capability and language. Click files to open examples.

Chat

Vision (image understanding)

Voice - Text-to-Speech

Voice - Speech-to-Text

OCR (basic / layout-preserving)

Embeddings

How to run examples

  • Run curl examples (make executable):
chmod +x path/to/example.sh
./path/to/example.sh
  • Run Python examples (install requests):
python3 path/to/example.py
  • Run JavaScript examples (Node.js may require a fetch polyfill):
node path/to/example.js
  • Run Go examples:
go run path/to/example.go

Switch from OpenAI

Qubrid is an OpenAI-compatible API layer, so you can keep the same request shapes and client patterns. The main change is the target endpoint and the API key source.

  • Keep the same OpenAI SDK or REST payloads.
  • Replace the OpenAI endpoint with https://platform.qubrid.com/v1.
  • Use QUBRID_API_KEY for authentication.
  • Keep the model, messages, and other request fields the same.

Python migration example

# Existing OpenAI usage
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

# Qubrid usage
client = OpenAI(
    base_url="https://platform.qubrid.com/v1",
    api_key=os.getenv("QUBRID_API_KEY"),
)

JavaScript migration example

// Existing OpenAI usage
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// Qubrid usage
const client = new OpenAI({
  baseURL: 'https://platform.qubrid.com/v1',
  apiKey: process.env.QUBRID_API_KEY,
});

Contributing

We welcome contributions that improve examples, expand model coverage, or add integrations.

  • Open issues for bug reports or missing examples.
  • Submit PRs with focused changes.
  • Keep code idiomatic and dependency minimal.
  • Add docs for new examples or runtime requirements.

Community & docs

License

This repository is licensed under the MIT License.

Chat completion fields

Use these fields in any language when making Qubrid chat completion requests.

  • Authorization (header, required): Bearer <token>
  • model (string, required): The language model to use.
  • messages (array, required): Conversation messages in chat format.
  • max_tokens (integer): Maximum number of tokens to generate.
  • temperature (number): Controls randomness in output.
  • top_p (number): Nucleus sampling parameter.
  • stream (boolean): Whether to stream responses incrementally.

Example chat message structure:

{
  "model": "openai/gpt-oss-120b",
  "messages": [
    {"role": "user", "content": "Summarize this support ticket into bullet-point next steps for the agent."}
  ],
  "max_tokens": 4096,
  "temperature": 0.7,
  "top_p": 1,
  "stream": true
}

Voice - Text-to-Speech

Convert text into natural-sounding speech using AI voice models.

  • Endpoint: POST /v1/audio/generations
  • Authorization: Bearer <token> (header)
  • Body (application/json):
    • model (string, required) - TTS model to use. Example: qwen3-tts-flash
    • text (string, required) - Text to synthesize.
    • voice (string, required) - Voice preset. Example: Cherry
    • language_type (string) - Language setting, e.g. Auto

Response (200 application/json):

{
  "created": 1710000000,
  "data": [
    { "url": "https://cdn.qubrid.com/generated/audio.mp3" }
  ]
}

Speech-to-Text - Transcription

Transcribe audio files to text.

  • Endpoint: POST /api/v1/qubridai/audio/transcribe
  • Authorization: Bearer <token> (header)
  • Body: multipart/form-data
    • file (file, required) - Audio file (wav, mp3, etc.)
    • model (string, required) - STT model. Example: openai/whisper-large-v3

Response (200 application/json):

{
  "text": "Today is a wonderful day to build something people love!"
}

Vision - Multimodal

Use vision-language models to analyze images via chat-style requests.

  • Endpoint: POST /v1/chat/completions
  • Authorization: Bearer <token> (header)
  • Body (application/json):
    • model (string, required) - Example: Qwen/Qwen3-VL-Plus
    • messages (array, required) - Chat-style payload that can include text and image items.
    • max_tokens (integer, default: 16384)
    • temperature (number, default: 0.1)
    • top_p (number, default: 1)
    • stream (boolean, default: true)

Response (200 application/json): standard OpenAI-compatible chat completion response or streamed chunks. Example fields:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1710000000,
  "model": "Qwen/Qwen3-VL-Plus",
  "choices": [{ "index": 0, "message": { /* ... */ }, "finish_reason": "stop" }],
  "usage": { "prompt_tokens": 120, "completion_tokens": 48, "total_tokens": 168 },
  "x_metrics": { "ttft_seconds": 0.41, "tps": 38.4, "total_time_seconds": 1.92 }
}

OCR - Document text extraction

OCR endpoints accept chat-style image inputs and return extracted text. Use the OCR-specialized vision model for best results.

  • Endpoint: POST /v1/chat/completions
  • Authorization: Bearer <token> (header)
  • Body (application/json):
    • model (string, required) - Example: Hunyuan/Hunyuan-OCR-1B
    • messages (array, required) - Chat-style input with text instructions and image content
    • max_tokens (integer, default: 8192)
    • temperature (number, default: 0.1)
    • top_p (number, default: 1)
    • stream (boolean, default: false)

Response (200 application/json): standard chat completion response containing extracted text and metadata:

{
  "id": "chatcmpl-ocr-123456",
  "object": "chat.completion",
  "created": 1710000000,
  "model": "Hunyuan/Hunyuan-OCR-1B",
  "choices": [{ "index": 0, "message": { /* extracted text */ }, "finish_reason": "stop" }]
}

About

Run DeepSeek, Qwen, Llama and 100+ OSS models using one OpenAI-compatible API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors