OpenAi - (platform\openAi.class.php)

CONST platform\openAi::MODEL_GPT = ['gpt-4o-2024-11-20', 'gpt-4o-mini', 'gpt-4.5-preview', 'gpt-4.1', 'gpt-4.1-mini'] Sprachmodelle
CONST platform\openAi::MODEL_REASONING = ['o4-mini', 'o3-mini', 'o3', 'o1-mini', 'o1', 'o1-pro'] Reasoning Sprachmodelle
CONST platform\openAi::MODEL_REALTIME = ['gpt-4o-mini-realtime-preview', 'gpt-4o-realtime-preview-2024-12-17'] Realtime Sprachmodelle
CONST platform\openAi::MODEL_AUDIO = ['gpt-4o-mini-audio-preview', 'gpt-4o-audio-preview-2024-12-17'] Audio Sprachmodelle
CONST platform\openAi::MODEL_SEARCH = ['gpt-4o-mini-search-preview', 'gpt-4o-search-preview'] Websuch Sprachmodelle
CONST platform\openAi::MODEL_COMPUTERUSE = ['computer-use-preview-2025-03-11'] AI Agent Sprachmodelle
CONST platform\openAi::MODEL_IMAGE = ['gpt-image-1', 'dall-e-3', 'dall-e-2'] Image Sprachmodelle
CONST platform\openAi::MODEL_TTS = ['gpt-4o-mini-tts', 'tts-1-1106', 'tts-1-hd-1106'] Text-To-Speech Sprachmodelle
CONST platform\openAi::MODEL_TRANS = ['gpt-4o-transcribe', 'gpt-4o-mini-transcribe', 'whisper-1'] Transcription Sprachmodelle
CONST platform\openAi::MODEL_EMBEDDINGS = ['text-embedding-3-small', 'text-embedding-3-large', 'text-embedding-ada-002'] Embeddings Sprachmodelle
CONST platform\openAi::MODEL_MODERATION = ['omni-moderation-2024-09-26'] Moderation Sprachmodelle
CONST platform\openAi::GPTIMAGEMIME = ['png', 'jpeg', 'jpg', 'webp', 'gif'] Bildgeneration Mime
CONST platform\openAi::MULTILANG = ['af', 'ar', 'hy', 'az', 'be', 'bs', 'bg', 'ca', 'zh', 'hr', 'cs', 'da',
'nl', 'en', 'et', 'fi', 'fr', 'gl', 'de', 'el', 'he', 'hi', 'hu', 'is', 'id', 'it', 'ja', 'kn', 'kk', 'ko',
'lv', 'lt', 'mk', 'ms', 'mr', 'mi', 'ne', 'no', 'fa', 'pl', 'pt', 'ro', 'ru', 'sr', 'sk', 'sl', 'es', 'sw',
'sv', 'tl', 'ta', 'th', 'tr', 'uk', 'ur', 'vi', 'cy']
Sprachen
CONST platform\openAi::TTSVOICE = ['alloy', 'ash', 'ballad', 'coral', 'echo', 'fable', 'onyx', 'nova', 'sage', 'shimmer', 'verse'] TTS Ausgabesprachen https://platform.openai.com/docs/guides/text-to-speech#voice-options
CONST platform\openAi::TTSAUDIOMIME = ['mp3', 'opus', 'aac', 'flac', 'wav', 'pcm'] Audio Ausgabeformate
CONST platform\openAi::TTSCHATVOICE = ['alloy', 'ash', 'ballad', 'coral', 'echo', 'sage', 'shimmer'] TTS Chat Ausgabesprachen
CONST platform\openAi::TTSCHATAUDIOMIME = ['wav', 'mp3', 'flac', 'opus', 'pcm16'] Audio Chat Ausgabeformate
CONST platform\openAi::TRANSAUDIOMIME = ['flac', 'mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'ogg', 'wav', 'webm'] Transcription Audio Mime
CONST platform\openAi::TRANSTEXTMIME = ['json', 'txt', 'srt', 'vtt'] Transcription Text Mime
CONST platform\openAi::IMAGESIZE = ['gpt-image-1' => ['1024x1024', '1536x1024', '1024x1536'],
'dall-e-3' => ['1024x1024', '1792x1024', '1024x1792'],
'dall-e-2' => ['256x256', '512x512', '1024x1024']]
Image Größen
CONST platform\openAi::FILEPURPOSE = ['assistants', 'vision', 'batch', 'fine-tune', 'user_data', 'evals'] Dateigebrauch

Audio

static platform\openAi::textToSpeech ($string $text = null[, $array $option = null])
$text enthält den zu sprechenden Text als string
$option optional; legt Optionen als $array fest
[
  'model' => 'gpt-4o-mini-tts' // wählt das Model aus (platform\openAi::MODEL_TTS)
  'voice' => 'ash' // wählt die Stimme als Integer aus (platform\openAi::TTSVOICE)
  'instructions' => null // kontrolliert die Stimme des erzeugten Tons mit zusätzlichen Anweisungen
  'response_format' | 'format' | 'mime' => new mime ('mp3') // gibt den Mimetyp an, siehe new mime() Objekt (platform\openAi::TTSAUDIOMIME)
  'speed' => null // wählt die Geschwindigkeit als float, zwischen 0.25 und 4.0; default ist 1.0
]
https://platform.openai.com/docs/api-reference/audio/createSpeech

gibt bei Erfolg den Audio-Inhalt einer Datei als string zurück; ansonsten null
$speech = platform\openAi::textToSpeech ('Hallo Welt');
static platform\openAi::speechToText ($string $object $audioFile = null[, $array $option = null])
$audioFile enthält die Audio Datei als string oder new file() Objekt (platform\openAi::TRANSAUDIOMIME)
$option optional; legt Optionen als $array fest
[
  'model' => 'gpt-4o-transcribe' // wählt das Model aus (platform\openAi::MODEL_TRANS)
  'language' => null // angabe der Sprache als im ISO-639-1 Format oder new lang() Objekt
  'prompt' => null // Text steuert den Modellstil oder setzt ein Audiosegment fort, entsprechend der Audiosprache
  'response_format' | 'format' | 'mime' => new mime ('json') // gibt den Mimetyp an, siehe new mime() Objekt (platform\openAi::TRANSTEXTMIME)
  'stream' => false // gibt als bool an ob ein Stream statt finden soll
  'temperature' | temp => null // Abtasttemperatur bestimmt die Zufälligkeit: Höher = zufälliger, niedriger = fokussierter. Bei 0 passt das Modell sie automatisch an
]
https://platform.openai.com/docs/api-reference/audio/createTranscription

gibt bei Erfolg den Text als string zurück; ansonsten null
$audio = new file ('media/aud/gpt.mp3');

platform\openAi::speechToText ($audio);

Image

static platform\openAi::image ($string $prompt = null[, $array $option = null])
$prompt enthält den Prompt für die Bildgenerierung
$option optional; legt Optionen als $array fest
[
  'background' => null // gibt an, ob das Bild ein transparenten Hintergrund hat ('transparent', 'opaque' oder 'auto')
  'model' => 'dall-e-3' // gibt das Image Modell an (platform\openAi::MODEL_IMAGE)
  'n' => 1 // gibt die Anzahl der zu generierenten Bilder an, mehr als 1 nur bei Dall-E 2, max 10
  'output_compression' => null // gibt die Kompression des Ausgabebildes an
  'output_format' | 'mime' => new mime('png') // gibt das Ausgabeformat des Bildes an
  'quality' => null // gibt die Qualität an die erzielt werden soll ('high' | 'hd', 'medium' oder 'low')
  'response_format' => 'b64_json' // gibt den Ausgabetyp an ('b64_json' oder 'url')
  'size' => null // gibt die Größe des zu generierenten Bilder an (platform\openAi::DALLESIZE)
  'style' => null // Bildstil kann zwischen 'vivid' für dramatische und 'natural' für natürlichere Bilder gewählt werden, nur für DALL-E 3 verfügbar
  'user' => null // einzigartiger Benutzer-Identifikator zur Überwachung und Erkennung von Missbrauch durch OpenAI
]
https://platform.openai.com/docs/api-reference/images/create

generiert ein Bild, und gibt ein array mit den Bildinformationen zurück; im Fehlerfall null
$img = platform\openAi::image ('strand am abend, gemütlich, entspannend, mit schönen lichtern, im stil von leonardo davinci');
static platform\openAi::imageEdit ()
https://platform.openai.com/docs/api-reference/images/createEdit

aktuell nur für Dall-E 2, muss noch ausgearbeitet werden
static platform\openAi::imageVariation ()
https://platform.openai.com/docs/api-reference/images/createVariation

aktuell nur für Dall-E 2, muss noch ausgearbeitet werden

Embeddings

static platform\openAi::embedding ($string $text = null[, $array $option = null])
$text Text der berechnet werden soll
$option optional; legt Optionen als $array fest
[
  'model' => 'text-embedding-3-small' // gibt das Embedding Modell an (platform\openAi::MODEL_EMBEDDINGS)
  'user' => null // gibt das Image Modell an (platform\openAi::MODEL_IMAGE)
]
https://platform.openai.com/docs/api-reference/embeddings/create

erfassen semantische Ähnlichkeiten zwischen Texten durch numerische Vektorrepräsentationen
$emp = platform\openAi::embedding ('Text der berechnet werden soll');

Model

static platform\openAi::models ([$string $model = null])
$model optional; gibt ein Model von OpenAi an
https://platform.openai.com/docs/api-reference/models

ruft alle Modelle von OpenAi ab, oder Information über ein einzelnes Model
platform\openAi::models ();

platform\openAi::models ('o3-mini');

Moderation

static platform\openAi::moderation ($string $array $input = null)
$input enthält Texte und/oder Bilder welche zu prüfen sind
https://platform.openai.com/docs/api-reference/moderations/create

prüft Texte und Bilder auf nicht angebrachte Ausdrucksweisen, es wird ein array ausgegeben; im Fehlerfall null
platform\openAi::moderation ('Du bist ein Arschloch!');

platform\openAi::moderation (['txt' => 'Du bist ein Arschloch!']);
platform\openAi::moderation (['img' => 'media/img/testsexual.png']);

platform\openAi::moderation (['Du bist ein Arschloch!', ['img' => 'media/img/testsexual.png'], ['txt' => 'Du bist ein Arschloch!']]);