:smirk: Chat Completions have arrived! As of daft...
# announcements
e
😏 Chat Completions have arrived! As of daft release 0.6.13, the
prompt
function supports sending requests via either the
v1/chat/completions/
or
v1/responses
endpoints to any OpenAI API compatible Server. Since it's introduction, the OpenAI API has been adopted by a majority industry as the standard means of chatting with Language Models. This includes use-cases like structured outputs where users can specify Pydantic Models to coerce model outputs to a specific schema. We’ve added compatibility with the completions endpoint so you can still leverage prompts structured outputs even if your provider doesn’t yet support responses. Additionally, as you can see below, prompt now supports
daft.DataType.Images
and
daft.Files
. In fact, the actual OpenAI Responses API only works with PDFs, but with
prompt
, @Colin Ho added the ability to inject any
text/*
mime type into the prompt context. This means that any markdown, html, or csv file you reference in a prompt is automatically added to your prompt input wrapped in xml tags!
Copy code
# /// script
# description = "Prompt Gemini 2.5 Flash Lite on OpenRouter with Images and Files"
# requires-python = ">=3.10, <3.13"
# dependencies = ["daft>=0.6.13", "openai", "numpy", "pillow"]
# ///
import os
import daft
from daft.functions import prompt, download, decode_image, file

daft.set_provider(
    "openai",
    base_url="<https://openrouter.ai/api/v1>",
    api_key=os.environ.get("OPENROUTER_API_KEY")
)

df = daft.from_pydict({
    "prompt": ["Whats in this image and file?"],
    "my_image": ["/Users/MyName/Desktop/SomeImage.png"],
    "my_file": ["/Users/MyName/Downloads/SomePdf.pdf"],
})

# Decode the image and file paths
df = df.with_column(
    "my_image",
    decode_image(download(daft.col("my_image")))
)

df = df.with_column(
    "my_file",
    file(daft.col("my_file"))
)

# Prompt Usage for Chat Completions with Images and Files
df = df.with_column(
    "result",
    prompt(
        messages=[daft.col("prompt"), daft.col("my_image"), daft.col("my_file")],
        system_message="You are a helpful assistant.", 
        model="google/gemini-2.5-flash-lite",
        provider="openai",
        use_chat_completions=True,
    )
)

print(df.select("result").to_pydict())
There has been a tremendous amount of development on the prompt api recently to get to this point. We can't wait to see what you build with
prompt
!
daft party 3
❤️ 2
🔥 2