File: vertex.py

package info (click to toggle)
anthropic-sdk-python 0.75.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,252 kB
  • sloc: python: 29,737; sh: 177; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 874 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import asyncio

from anthropic import AnthropicVertex, AsyncAnthropicVertex


def sync_client() -> None:
    print("------ Sync Vertex ------")

    client = AnthropicVertex()

    message = client.messages.create(
        model="claude-sonnet-4@20250514",
        max_tokens=100,
        messages=[
            {
                "role": "user",
                "content": "Hello!",
            }
        ],
    )
    print(message.to_json())


async def async_client() -> None:
    print("------ Async Vertex ------")

    client = AsyncAnthropicVertex()

    message = await client.messages.create(
        model="claude-sonnet-4@20250514",
        max_tokens=1024,
        messages=[
            {
                "role": "user",
                "content": "Hello!",
            }
        ],
    )
    print(message.to_json())


sync_client()
asyncio.run(async_client())