Skip to content

Latest commit

 

History

History
121 lines (103 loc) · 3.09 KB

api.restful.md

File metadata and controls

121 lines (103 loc) · 3.09 KB

curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{ "model": "gpt-4o", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What’s in this image?" }, { "type": "image_url", "image_url": { "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" } } ] } ], "max_tokens": 300 }'

curl 127.0.0.1:8080/inference
-H "Content-Type: multipart/form-data"
-F file="/Users/yixin0909zhang/Desktop/whisper.cpp/test_audio.mp3.wav"
-F temperature="0.0"
-F temperature_inc="0.2"
-F response_format="json"

curl https://api.openai.com/v1/audio/speech
-H "Authorization: Bearer $OPENAI_API_KEY"
-H "Content-Type: application/json"
-d '{ "model": "tts-1", "input": "The quick brown fox jumped over the lazy dog.", "voice": "alloy" }'
--output speech.mp3

curl http://localhost:11434/v1/chat/completions
-H "Content-Type: application/json"
-d '{ "model": "llama2", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hello!" } ] }

import OpenAI from 'openai'

const openai = new OpenAI({ baseURL: 'http://localhost:11434/v1', apiKey: 'ollama', // required but unused })

const completion = await openai.chat.completions.create({ model: 'llama2', messages: [{ role: 'user', content: 'Why is the sky blue?' }], })

console.log(completion.choices[0].message.content)

curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{ "model": "gpt-4-turbo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What’s in this image?" }, { "type": "image_url", "image_url": { "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" } } ] } ], "max_tokens": 300 }'

// curl --request POST
// --url https://api.openai.com/v1/audio/transcriptions
// --header "Authorization: Bearer $OPENAI_API_KEY"
// --header 'Content-Type: multipart/form-data'
// --form file=@/path/to/file/audio.mp3
// --form model=whisper-1

// curl https://api.openai.com/v1/audio/speech \

// -H "Authorization: Bearer $OPENAI_API_KEY"
// -H "Content-Type: application/json"
// -d '{ // "model": "tts-1", // "input": "Today is a wonderful day to build something people love!", // "voice": "alloy" // }'
// --output speech.mp3