# 输出类型

Canonical URL: https://developers.iagenify.com/zh/sdk/concepts/outputs/
Language: zh

结果是输出列表。 询问形状是将作品变成一种可以不读英文而可以操作的东西。

Status: outputs[] · schema

## 回到什么 {#shape}

```javascript
{
  outputs: [{ type, content, mime?, description? }],
  usage:   { credits, inputTokens, outputTokens },
  model:   "gemini-3.5-flash",
  service: "text-to-text"
}
```

| 类型类型类型 | 内容持有 |
| --- | --- |
| 文字文字文字文字 | 字符串 |
| json json 支 | a a , a JSON 字符串 - 分析 |
| 音频 视频 | 基数64, MIME 设置 |
| 嵌入 | 数组数组 |

## 请求形状 {#asking}

两种方式,他们做不同的工作。 `schema` 其给出的每个答案都由会话决定。 `outputs` 在一个单一的呼唤形状上 呼唤。

```javascript
// Every answer from this session has this shape
const extractor = await api.models.create({
  model: "gemini-3.5-flash",
  memory: false,
  schema: {
    type: "object",
    properties: { company: { type: "string" }, amount: { type: "number" } },
    required: ["company", "amount"],
  },
});

const { outputs } = await extractor.generate({ inputs });
const invoice = JSON.parse(outputs[0].content);
```

```javascript
// Just this call, and more than one thing at a time
await assistant.generate({
  inputs: [{ type: "text", content: "Describe the product, then illustrate it." }],
  outputs: [
    { type: "text",  description: "One paragraph of copy" },
    { type: "image", description: "A square product shot on a plain background" },
  ],
});
```

## 书写二进书 {#binary}

```javascript
const [picture] = result.outputs.filter((o) => o.type === "image");

await fs.writeFile("product.png", Buffer.from(picture.content, "base64"));

// or keep it on a storage, through the SDK
const file = api.files.create({
  name: "product.png",
  content: picture.content,
  mimeType: picture.mime,
});
await file.save({ path: "./product.png" });
```

> **将内容作为基数64,而不是文本**
>
> 以任何假设的方式传递双元内容 UTF-8它腐蚀了它 第一次机会就解码成字节

```python
{
    "outputs": [{"type": ..., "content": ..., "mime": ..., "description": ...}],
    "usage": {"credits": ..., "inputTokens": ..., "outputTokens": ...},
    "model": "gemini-3.5-flash",
    "service": "text-to-text",
}
```

```python
import json

# Every answer from this session has this shape
extractor = api.models.create(
    model="gemini-3.5-flash",
    memory=False,
    schema={
        "type": "object",
        "properties": {"company": {"type": "string"}, "amount": {"type": "number"}},
        "required": ["company", "amount"],
    },
)

outputs = extractor.generate(inputs=inputs)["outputs"]
invoice = json.loads(outputs[0]["content"])
```

```python
# Just this call, and more than one thing at a time
assistant.generate(
    inputs=[{"type": "text", "content": "Describe the product, then illustrate it."}],
    outputs=[
        {"type": "text", "description": "One paragraph of copy"},
        {"type": "image", "description": "A square product shot on a plain background"},
    ],
)
```

```python
import base64
from pathlib import Path

picture = next(o for o in result["outputs"] if o["type"] == "image")

Path("product.png").write_bytes(base64.b64decode(picture["content"]))

# or keep it on a storage, through the SDK
file = api.files.create(
    name="product.png",
    content=base64.b64decode(picture["content"]),
    mime_type=picture.get("mime"),
)
file.save(path="./product.png")
```
