Skip to content

Commit 82914b7

Browse files
author
BitsAdmin
committed
Merge branch 'chore/add_image_example' into 'integration_2024-10-17_473370829314'
feat: [development task] ark-runtime-manual-Python (810333) See merge request iaasng/volcengine-python-sdk!401
2 parents 50dbc9f + 6eb7fde commit 82914b7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from volcenginesdkarkruntime import Ark
2+
3+
# Authentication
4+
# 1.If you authorize your endpoint using an API key, you can set your api key to environment variable "ARK_API_KEY"
5+
# or specify api key by Ark(api_key="${YOUR_API_KEY}").
6+
# Note: If you use an API key, this API key will not be refreshed.
7+
# To prevent the API from expiring and failing after some time, choose an API key with no expiration date.
8+
9+
# 2.If you authorize your endpoint with Volcengine Identity and Access Management(IAM),
10+
# set your api key to environment variable "VOLC_ACCESSKEY", "VOLC_SECRETKEY"
11+
# or specify ak&sk by Ark(ak="${YOUR_AK}", sk="${YOUR_SK}").
12+
# To get your ak&sk, please refer to this document(https://www.volcengine.com/docs/6291/65568)
13+
# For more information,please check this document(https://www.volcengine.com/docs/82379/1263279)
14+
client = Ark()
15+
16+
# Image input:
17+
response = client.chat.completions.create(
18+
model="${YOUR_ENDPOINT_ID}",
19+
messages=[
20+
{
21+
"role": "user",
22+
"content": [
23+
{"type": "text", "text": "这是哪里?"},
24+
{
25+
"type": "image_url",
26+
"image_url": {
27+
"url": "https://ark-project.tos-cn-beijing.ivolces.com/images/view.jpeg"
28+
}
29+
},
30+
],
31+
}
32+
]
33+
)
34+
35+
print(response.choices[0])

0 commit comments

Comments
 (0)