> For the complete documentation index, see [llms.txt](https://doc.xspark.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.xspark.cn/api/obtain-credentials/huo-qu-api-token.md).

# 获取 API Token

在调用 Xspark API 之前，您需要先在控制台中生成用于身份认证的 API Key。请按照以下步骤操作：

{% stepper %}
{% step %}
**登录 Xspark**

访问 Xspark 首页，使用您的账号密码完成登录。
{% endstep %}

{% step %}
**进入 API Key 管理页面**

&#x20;登录后，在左侧导航栏点击「我的账户」，点击顶部选项卡中的「[API Key 管理](https://dashboard.xspark.cn/account/tokens/)」。

<figure><img src="https://4025688386-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqVlAkAcoAtJp5GwGzjrC%2Fuploads%2F5v5Cv8YbyRolzdrJy4e7%2Fimage.png?alt=media&amp;token=94799700-c900-44cc-aad5-7ccb9e08f03e" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
每个账户均有一个系统默认 API Key，可以直接复制使用或创建新 API Key。

<figure><img src="https://4025688386-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqVlAkAcoAtJp5GwGzjrC%2Fuploads%2FUlliTQpGX8PZ7PJzN1tr%2Fimage.png?alt=media&amp;token=06156acd-0a9a-4750-8aa8-e03fcab39d80" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**新增 API Key**

点击右侧“新增”。

<figure><img src="https://4025688386-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqVlAkAcoAtJp5GwGzjrC%2Fuploads%2FYUefcp4oOjypmZsrvlFB%2Fimage.png?alt=media&amp;token=10c20f70-a609-4601-94ad-b3d2314042cc" alt=""><figcaption></figcaption></figure>

输入 API Key 名称，选择到期时间，点击“确认创建”。如果希望 API Key 不过期，可以勾选永久有效。

<figure><img src="https://4025688386-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqVlAkAcoAtJp5GwGzjrC%2Fuploads%2FOEmTjYWzpyUUQ9o7IcgZ%2Fimage.png?alt=media&amp;token=b6214a15-0092-4a41-ac1d-140e7c49fc83" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**复制 API Key**

直接点击 API Key，即可复制完整字符串。

<figure><img src="https://4025688386-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqVlAkAcoAtJp5GwGzjrC%2Fuploads%2FP3dYOH6xnBFNpsMmIHXs%2Fimage.png?alt=media&amp;token=842caae1-7b4c-43ce-8fad-96153fd7a088" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}
