> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 產生 Bria 向量圖形

> 使用 CometAPI POST /bria/text-to-vector 搭配 Bria Base（Beta）從文字產生可編輯、可縮放的向量資產，適用於圖示、標誌與插圖。

## 概述

從文字 Prompt 產生高品質、可編輯的向量圖形資產。非常適合使用 Bria 專有的文字轉圖像基礎模型來建立可縮放的圖示、標誌與插圖。

<Note>
  此介面等同於 `https://engine.prod.bria-api.com/v1/text-to-vector/base/3.2`

  如需詳細資訊，請參閱 [Bria 官方文件](https://docs.bria.ai/image-generation/v1-endpoints/text-to-vector-base)。
</Note>

## 何時使用

當最終資產需要保持可編輯或可縮放時，請使用此端點，例如圖示、簡單插圖、標誌與版面圖形。若你需要擬真細節或複雜紋理，則改用點陣圖像生成。

## 第一個請求

先從簡短的 Prompt 開始，描述物件、風格與預期用途。第一個請求請保持簡單，確認向量輸出可用後，再加入品牌、顏色或構圖限制。

## 讀取回應

回應會透過 API playground 傳回向量輸出欄位。若你的工作流程需要長期儲存或後續編輯，請及時保存傳回的資產。


## OpenAPI

````yaml api/openapi/image/bria/post-generate-vector-graphics-base.openapi.json POST /bria/text-to-vector
openapi: 3.1.0
info:
  title: Generate Vector Graphics - Base (Beta) API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /bria/text-to-vector:
    post:
      summary: Generate Vector Graphics - Base (Beta)
      operationId: generate_vector_graphics_base
      parameters:
        - name: Content-Type
          in: header
          required: false
          description: ''
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - prompt
                - guidance_method_2_scale
              properties:
                prompt:
                  type: string
                  description: >-
                    The prompt you would like to use to generate images. Bria
                    currently supports prompts in English only.
                  default: A flat vector illustration of a sailboat at sunset
                num_results:
                  type: integer
                  description: >-
                    The aspect ratio of the image. When a ControlNet is being
                    used, the aspect ratio is defined by the guidance image and
                    this parameter is ignored.

                    Default `4`
                sync:
                  type: boolean
                  description: >-
                    Determines the response mode. When true, responses are
                    synchronous. With false, responses are asynchronous,
                    immediately providing URLs for images that are generated in
                    the background. Use polling for the URLs to retrieve images
                    once ready.

                    Default `false`
                aspect_ratio:
                  type: string
                  description: >-
                    The aspect ratio of the image.


                    Default `"1:1"`


                    Enum `"1:1"` `"2:3"` `"3:2"` `"3:4"` `"4:3"` `"4:5"` `"5:4"`
                    `"9:16"` `"16:9"`
                seed:
                  type: integer
                  description: >-
                    You can choose whether you want your generated result to be
                    random or predictable. You can recreate the same result in
                    the future by using the seed value of a result from the
                    response with the prompt, model type and model version. You
                    can exclude this parameter if you are not interested in
                    recreating your results. This parameter is optional.
                negative_prompt:
                  type: string
                  description: >-
                    Specify here elements that you didn't ask in the prompt, but
                    are being generated, and you would like to exclude. This
                    parameter is optional. Bria currently supports prompts in
                    English only.
                steps_num:
                  type: integer
                  description: >-
                    The number of iterations the model goes through to refine
                    the generated image. This parameter is optional.

                    Default `30`
                text_guidance_scale:
                  type: integer
                  description: >-
                    Determines how closely the generated image should adhere to
                    the input text description. This parameter is optional.

                    Default `5`
                prompt_content_moderation:
                  type: boolean
                  description: >-
                    When enabled (default: true), the input prompt is scanned
                    for NSFW or ethically restricted terms before image
                    generation. If the prompt violates Bria's ethical
                    guidelines, the request will be rejected with a 408 error.

                    Default `true`
                content_moderation:
                  type: boolean
                  description: >-
                    When enabled, applies content moderation to both input
                    visuals and generated outputs.


                    For input images:


                    - Processing stops at the first image that fails moderation

                    - Returns a 422 error with details about which parameter
                    failed


                    For synchronous requests (sync=true):


                    - If all generated images fail moderation, returns a 422
                    error

                    - If some images pass and others fail, returns a 200
                    response with successful generations and "blocked" objects
                    for failed ones


                    For asynchronous requests (sync=false):


                    - Failed images are replaced with zero-byte files at their
                    placeholder URLs

                    - Successful images are stored at their original placeholder
                    URLs


                    Default `false`
                ip_signal:
                  type: boolean
                  description: >-
                    Flags prompts with potential IP content. If detected, a
                    warning will be included in the response.


                    Default `false`
                guidance_method_1:
                  type: string
                  description: >-
                    Which guidance type you would like to include in the
                    generation. Up to 2 guidance methods can be combined during
                    a single inference. This parameter is optional.

                    Enum `"controlnet_canny"` `"controlnet_depth"`
                    `"controlnet_recoloring"` `"controlnet_color_grid"`
                guidance_method_1_scale:
                  type: integer
                  description: |-
                    The impact of the guidance.

                    Default `1`
                guidance_method_1_image_file:
                  type: string
                  description: >-
                    The image that should be used as guidance, in base64 format,
                    with the method defined in guidance_method_1. Accepted
                    formats are jpeg, jpg, png, webp. Maximum file size 12MB. If
                    more then one guidance method is used, all guidance images
                    must be of the same aspect ratio, and this will be the
                    aspect ratio of the generated results. If guidance_method_1
                    is selected, an image must be provided.
                guidance_method_2:
                  type: string
                  description: >-
                    Which guidance type you would like to include in the
                    generation. Up to 2 guidance methods can be combined during
                    a single inference. This parameter is optional.

                    Enum `"controlnet_canny"` `"controlnet_depth"`
                    `"controlnet_recoloring"` `"controlnet_color_grid"`
                guidance_method_2_scale:
                  type: integer
                  description: |-
                    The impact of the guidance.

                    Default `1`
                  default: 1
                guidance_method_2_image_file:
                  type: string
                  description: >-
                    The image that should be used as guidance, in base64 format,
                    with the method defined in guidance_method_2. Accepted
                    formats are jpeg, jpg, png, webp. Maximum file size 12MB. If
                    more then one guidance method is used, all guidance images
                    must be of the same aspect ratio, and this will be the
                    aspect ratio of the generated results. If guidance_method_1
                    is selected, an image must be provided.
                image_prompt_mode:
                  type: string
                  description: >-
                    - `regular`: Uses the image’s content, style elements, and
                    color palette to guide generation.

                    - `style_only`: Uses the image’s high-level style elements
                    and color palette to influence the generated output. The
                    support for image prompt is currently available only when
                    model_version="2.3".


                    Default `"regular"`


                    Enum `"regular"` `"style_only"`
                image_prompt_file:
                  type: string
                  description: >-
                    The image file to be used as guidance, in base64 format.
                    Accepted formats are jpeg, jpg, png, webp. The support for
                    image prompt is currently available only when
                    model_version="2.3". Maximum file size 12MB. This image can
                    be of any aspect ratio, even when it's not alligned with the
                    one defined in the parameter 'aspect_ratio' or by visuals
                    provided to the ControlNets.
                image_prompt_urls:
                  type: array
                  description: >-
                    A list of URLs of images that should be used as guidance.
                    The images can be of different aspect ratios. Accepted
                    formats are jpeg, jpg, png, webp. The URLs should point to
                    accessible, publicly available images. The support for image
                    prompt is currently available only when model_version="2.3".
                  items:
                    type: string
                    description: url
                image_prompt_scale:
                  type: integer
                  description: >-
                    The impact of the provided image on the generated results. A
                    value between 0.0 (no impact) and 1.0 (full impact).

                    Default `1`
              default:
                prompt: A flat vector illustration of a sailboat at sunset
                guidance_method_2_scale: 1
            examples:
              Example 1:
                summary: Example 1
                value:
                  prompt: a book
                  num_results: 2
                  sync: false
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties: {}
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            curl https://api.cometapi.com/bria/text-to-vector \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                  "prompt": "a book",
                  "num_results": 2,
                  "sync": false
                }'
        - lang: Python
          label: Default
          source: >
            import os

            import requests


            response = requests.post(
                "https://api.cometapi.com/bria/text-to-vector",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                        "prompt": "a book",
                        "num_results": 2,
                        "sync": False
                },
            )


            print(response.json())  # the route responds synchronously with
            result[].urls
        - lang: JavaScript
          label: Default
          source: >
            const response = await
            fetch("https://api.cometapi.com/bria/text-to-vector", {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                        "prompt": "a book",
                        "num_results": 2,
                        "sync": false
                    }),
            });


            console.log(await response.json()); // the route responds
            synchronously with result[].urls
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````