import base64, io, zipfile
from vlmrun.client import VLMRun
from vlmrun.client.types import AgentSkill, InlineSkillSource
# Build a skill zip in memory
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w") as zf:
zf.writestr("SKILL.md", """\
---
name: invoice-extraction
description: Extract structured data from invoices
---
# Invoice Extraction
Extract invoice_id, date, and total_amount from the provided document.
""")
zf.writestr("schema.json", '{"type":"object","properties":{"invoice_id":{"type":"string"},"date":{"type":"string"},"total_amount":{"type":"number"}},"required":["invoice_id","date","total_amount"]}')
bundle = base64.b64encode(buf.getvalue()).decode()
client = VLMRun(api_key="<VLMRUN_API_KEY>")
response = client.agent.completions.create(
model="vlmrun-orion-1:auto",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "Extract data from this invoice."},
{"type": "file_url", "file_url": {"url": "https://example.com/invoice.pdf"}}
]
}
],
skills=[
AgentSkill(
type="inline",
name="invoice-extraction",
description="Extract structured data from invoices",
source=InlineSkillSource(data=bundle),
)
],
)