Upload Reference Image
Immutable Catalog Entry
This descriptor comes from the active versioned Portal catalog.
- Contract tier:
agent_ready - Risk:
write - Catalog version:
leonardo-ai-2026.07.12.1 - Descriptor hash:
823610481454ab7a63600612d035c33789aec93109fffbf10eeb5927961ac30f
Upload a reference image from URL, local file path, data URL, or base64. Accepts optional metadata for agent-side traceability. Requires the request-scoped x-leonardo-api-key Portal field and contacts Leonardo.Ai.
Request Body
{
"jsonrpc": "2.0",
"id": "leonardo-ai-leonardo-upload-reference-image-example",
"method": "tools/call",
"params": {
"name": "leonardo-ai.leonardo_upload_reference_image",
"arguments": {
"body": "",
"file": "",
"name": "",
"target": "init_image",
"data_url": "",
"filename": "",
"metadata": "",
"extension": "",
"file_path": "",
"image_url": ""
}
}
}
Arguments Schema
{
"type": "object",
"properties": {
"body": {
"anyOf": [
{
"type": "object",
"additionalProperties": true
},
{
"type": "null"
}
],
"default": null,
"description": "Optional Leonardo request body additions using provider parameter names exactly."
},
"file": {
"anyOf": [
{
"type": "object",
"additionalProperties": true
},
{
"type": "null"
}
],
"default": null,
"description": "Optional ChatGPT/OpenAI file object. When provided, the server uses download_url, url, file_path, local_file_path, filename, and mime_type from the object when present."
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional agent-side label for this upload, such as a scene or asset name. This is not sent to Leonardo's upload-init JSON body."
},
"target": {
"enum": [
"init_image",
"canvas_init_image",
"dataset_image",
"media"
],
"type": "string",
"default": "init_image",
"description": "Leonardo upload target."
},
"data_url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Base64 data URL to upload."
},
"filename": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional original filename for multipart upload metadata and extension inference. This is not sent to the Leonardo upload-init JSON body."
},
"metadata": {
"anyOf": [
{
"type": "object",
"additionalProperties": true
},
{
"type": "null"
}
],
"default": null,
"description": "Optional agent-side metadata to echo in the response for traceability. Leonardo's upload-init endpoint only accepts extension, so metadata is not forwarded to the provider."
},
"extension": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "png, jpg, jpeg, or webp. Required for base64_data."
},
"file_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Local file path on the MCP server/container to upload. The path must be inside LEONARDO_LOCAL_UPLOAD_ROOTS, which defaults to /uploads, /tmp, and /data/uploads."
},
"image_url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Remote HTTPS image URL to download and upload as a reference image."
},
"mime_type": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional MIME type such as image/png, image/jpeg, or image/webp for extension inference. This is not sent to the Leonardo upload-init JSON body."
},
"dataset_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Required when target is dataset_image."
},
"base64_data": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Raw base64 image content to upload."
},
"request_body": {
"anyOf": [
{
"type": "object",
"additionalProperties": true
},
{
"type": "null"
}
],
"default": null,
"description": "Optional Leonardo request body additions using provider parameter names exactly."
},
"local_file_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Alias for file_path for agents that use a local_file_path name."
}
},
"additionalProperties": false
}
Output Schema
{
"type": "object",
"description": "Leonardo MCP result. ok=false, provider_ok=false, a failed status, or an error field represents a semantic failure even when transport delivery succeeded.",
"additionalProperties": true
}
Code Examples
- cURL
- Node.js
- Python
curl -X POST 'https://portal.madpanda3d.com/api/mcp' \
-H 'Authorization: Bearer mad_live_***' \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "leonardo-ai-leonardo-upload-reference-image-example",
"method": "tools/call",
"params": {
"name": "leonardo-ai.leonardo_upload_reference_image",
"arguments": {
"body": "",
"file": "",
"name": "",
"target": "init_image",
"data_url": "",
"filename": "",
"metadata": "",
"extension": "",
"file_path": "",
"image_url": ""
}
}
}'
const response = await fetch('https://portal.madpanda3d.com/api/mcp', {
method: 'POST',
headers: {
Authorization: 'Bearer mad_live_***',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"jsonrpc": "2.0",
"id": "leonardo-ai-leonardo-upload-reference-image-example",
"method": "tools/call",
"params": {
"name": "leonardo-ai.leonardo_upload_reference_image",
"arguments": {
"body": "",
"file": "",
"name": "",
"target": "init_image",
"data_url": "",
"filename": "",
"metadata": "",
"extension": "",
"file_path": "",
"image_url": ""
}
}
}),
});
const data = await response.json();
console.log(data);
import requests
url = 'https://portal.madpanda3d.com/api/mcp'
headers = {
'Authorization': 'Bearer mad_live_***',
'Content-Type': 'application/json',
}
payload = {
"jsonrpc": "2.0",
"id": "leonardo-ai-leonardo-upload-reference-image-example",
"method": "tools/call",
"params": {
"name": "leonardo-ai.leonardo_upload_reference_image",
"arguments": {
"body": "",
"file": "",
"name": "",
"target": "init_image",
"data_url": "",
"filename": "",
"metadata": "",
"extension": "",
"file_path": "",
"image_url": ""
}
}
}
response = requests.post(url, headers=headers, json=payload, timeout=60)
print(response.json())
Example Responses
- 200 Success
- 502 Upstream Error
{
"ok": true,
"message": "Tool leonardo-ai.leonardo_upload_reference_image executed successfully.",
"note": "Response shape varies by MCP tool. Inspect live responses for exact fields."
}
{
"ok": false,
"classification": "upstream_http_error",
"message": "Upstream MCP returned a non-success status."
}