37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import OpenAI from "openai";
|
|
|
|
const client = new OpenAI({
|
|
baseURL: "http://localhost:3000/openai/v1",
|
|
});
|
|
|
|
const response = await client.chat.completions.create({
|
|
model: "tensorzero::model_name::openai::gpt-4o-mini",
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: "Do the images share any common features?",
|
|
},
|
|
// Remote image of Ferris the crab
|
|
{
|
|
type: "image_url",
|
|
image_url: {
|
|
url: "https://raw.githubusercontent.com/tensorzero/tensorzero/eac2a230d4a4db1ea09e9c876e45bdb23a300364/tensorzero-core/tests/e2e/providers/ferris.png",
|
|
},
|
|
},
|
|
// One-pixel orange image encoded as a base64 string
|
|
{
|
|
type: "image_url",
|
|
image_url: {
|
|
url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+O/P8B8ABe0CTsv8mHgAAAAASUVORK5CYII=",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|
|
|
|
console.dir(response, { depth: null });
|