[upload] Add Docs

This commit is contained in:
LittleMouse
2025-04-23 17:45:47 +08:00
parent 6dd2b784f7
commit 17d75259ea
4 changed files with 142 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
# Chat Completions
The Chat Completions API endpoint will generate a model response from a list of messages comprising a conversation.
# Create chat completion
`post https://api.openai.com/v1/chat/completions`
```python
from openai import OpenAI
openai = OpenAI(
api_key="sk-",
base_url="http://192.168.20.186:8000/v1"
)
completion = client.chat.completions.create(
model="qwen2.5-0.5b-p256-ax630c",
messages=[
{"role": "developer", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
```
## Request body
### messages `array` <span style="color: red;">Required</span>
A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.
### model `string` <span style="color: red;">Required</span>
Model ID used to generate the response, like `qwen2.5-0.5b-p256-ax630c` or `deepseek-r1-1.5b-p256-ax630c`. StackFlow offers a wide range of models with different capabilities, performance characteristics. Refer to the model Docs to browse and compare available models.
### audio
`Audio output is not currently supported`
### function_call
`function_call is not currently supported`
### max_tokens `integer` Optional
The maximum number of tokens that can be generated in the chat completion.
### response_format `object` Optional
An object specifying the format that the model must output.
`Currently only supported format is json_object.`
+20
View File
@@ -0,0 +1,20 @@
# Models
List and describe the various models available in the API. You can refer to the Models documentation to understand what models are available and the differences between them.
# List models
`get http://192.168.20.186:8000/v1/models`
Lists the currently available models, and provides basic information about each one such as the owner and availability.
```python
from openai import OpenAI
openai = OpenAI(
api_key="sk-",
base_url="http://192.168.20.186:8000/v1"
)
client.models.list()
```
## Returns
A list of model objects.
+45
View File
@@ -0,0 +1,45 @@
# Audio
Learn how to turn audio into text or text into audio.
# Create speech
post https://192.168.20.186:8000/v1/audio/speech
Generates audio from the input text.
```python
from pathlib import Path
from openai import OpenAI
openai = OpenAI(
api_key="sk-",
base_url="http://192.168.20.186:8000/v1"
)
speech_file_path = Path(__file__).parent / "speech.mp3"
with openai.audio.speech.with_streaming_response.create(
model="gpt-4o-mini-tts",
voice="alloy",
input="The quick brown fox jumped over the lazy dog."
) as response:
response.stream_to_file(speech_file_path)
```
## Request body
### input `string` <span style="color: red;">Required</span>
The text to generate audio for. The maximum length is `1024` characters.
### model `string` <span style="color: red;">Required</span>
One of the available TTS models: `melotts-zh-cn`, `melotts-en-us`.
### voice
`Voice selection is not currently supported`
### response_format `string` Optional Defaults to mp3
The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
### speed `number` Optional Defaults to 1
The speed of the generated audio. Select a value from `0.25` to `2.0`. `1.0` is the default.
## Returns
The audio file content.
+33
View File
@@ -0,0 +1,33 @@
# Create transcription
`post http://192.168.20.186:8000/v1/audio/transcriptions`
Transcribes audio into the input language.
```python
from openai import OpenAI
client = OpenAI(
api_key="sk-",
base_url="http://192.168.20.186:8000/v1"
)
audio_file = open("speech.mp3", "rb")
transcript = client.audio.transcriptions.create(
model="whisper-tiny",
language="en",
file=audio_file
)
```
## Request body
### file file Required
The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
### model `string` <span style="color: red;">Required</span>
ID of the model to use. The options are `whisper-tiny`, `whisper-base`, and `whisper-small`.
### language `string` <span style="color: red;">Required</span>
The language of the input audio. Supplying the input language in ISO-639-1 (e.g. en) format will improve accuracy and latency.
### response_format string Optional
Defaults to json
`Currently only supported format is json.`