This guide shows how to turn the Giotto Responses API into application features. Start with the question-answering example, then try asking about a specific public web page.
Before you begin
Complete Quick start: Make your first API request with Python. The examples below assume that the Giotto SDK is installed and the GIOTTO_* environment variables are configured.
Use case 1: Answer user questions
What you will build
A small Python function that accepts a question and returns a concise answer. This pattern can support an internal assistant, help interface, or developer tool.
Example
from g_client import GiottoClient
client = GiottoClient()
def answer_question(question: str) -> str:
response = client.responses.create(
model="giotto-alto",
instructions=(
"You are a concise technical assistant. "
"State when the available information is insufficient."
),
input=question,
effort="medium",
)
return response.output_text
print(answer_question("What is the difference between a list and a tuple in Python?"))Production considerations
- Validate and limit user input before sending it to the API.
- Keep developer instructions in application code rather than accepting them from untrusted users.
- Set an application timeout and handle authentication, rate-limit, balance, and service errors.
- Log the request ID for diagnosis, but avoid logging secrets or sensitive content.
- Tell users when an answer is generated and may require verification.
- Use an appropriate source of evidence when answers need current or verifiable facts.
Use case 2: Answer a question about a web page
What you will build
Give Giotto the URL of a public page and ask a question about its content. The deployed giotto-alto orchestrator has a URL-crawling tool that it can call to read a page.
Supply a full https:// URL to a publicly accessible page. The SDK does not expose a separate web-search option or a structured response.sources field.
Example request
from g_client import GiottoClient
client = GiottoClient()
url = "https://www.python.org/about/"
response = client.responses.create(
model="giotto-alto",
instructions=(
"Read the page at the supplied URL before answering. "
"If you cannot access it, say so."
),
input=f"According to {url}, what is Python used for?",
)
print(response.output_text)Expected behavior
The orchestrator can call its URL-crawling tool to read the page and then produce an answer. Tool selection is handled by the deployed orchestrator; this request does not guarantee that a crawl occurs. To inspect tool activity, use the event-streaming interface described in the Python SDK reference.
Production considerations
- Validate user-supplied URLs and apply your application's URL access policy.
- Handle pages that are unavailable, blocked, or too large to process.
- Show the URL you supplied alongside the answer if users need to inspect the source.
- Verify important claims against the page content; the SDK does not provide structured citations.
Use case 3: Ask a question about an uploaded image
What you will build
Send a bar-chart image with a question and print the model's answer. Download the sample bar chart and save it as bar-chart-example.png beside your Python script.
The sample image is titled “Favorite Graphs.” and is available from Wikimedia Commons.
Example request
from pathlib import Path
from g_client import GiottoClient
client = GiottoClient()
image_path = Path(__file__).with_name("bar-chart-example.png")
response = client.responses.create(
model="giotto-alto",
input=(
"Read the attached bar chart. What is its title, which graph type "
"is most popular, and what value does that bar show? "
"If you cannot view the image, say so."
),
files=[image_path],
)
print(response.output_text)Expected result
The answer should identify the title as “Favorite Graphs” and “Line Graphs” as the highest bar, with a value of 9. This request was verified against the stage giotto-alto model; the precise wording may vary.
The SDK sends requests containing files as multipart/form-data. Keep the image on the server side of your application; do not expose API credentials in browser code.
Optional pattern: Start a long-running request without waiting
For work that can take longer, start the request and wait for it later:
started = client.responses.create(
model="giotto-alto",
input="Prepare a structured comparison of the supplied options.",
poll=False,
)
print(f"Started request: {started.request_id}")
completed = client.responses.wait(started.request_id)
print(completed.output_text)Store the request ID if another process or job will retrieve the result.
Comments
0 comments
Please sign in to leave a comment.