-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_call.py
More file actions
64 lines (52 loc) · 1.81 KB
/
basic_call.py
File metadata and controls
64 lines (52 loc) · 1.81 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Run: uv run examples/basic_call.py
"""Basic example: call AI CLI tools."""
import asyncio
from ai_cli_runner import call_ai_cli
CLAUDE_MODEL = "claude-haiku-4-5"
GEMINI_MODEL = "gemini-2.5-flash"
CURSOR_MODEL = "gpt-5.4-nano-none"
# CLI flags needed for non-interactive/headless execution
CLAUDE_FLAGS = ["--dangerously-skip-permissions"]
GEMINI_FLAGS = ["--skip-trust"]
CURSOR_FLAGS = ["--trust"]
TIMEOUT_MINUTES = 2
async def main() -> None:
# Call all 3 providers in parallel
results = await asyncio.gather(
call_ai_cli(
prompt="What is the capital of France?",
ai_provider="claude",
ai_model=CLAUDE_MODEL,
ai_cli_timeout=TIMEOUT_MINUTES,
cli_flags=CLAUDE_FLAGS,
output_format="json",
),
call_ai_cli(
prompt="What is 2 + 2?",
ai_provider="gemini",
ai_model=GEMINI_MODEL,
ai_cli_timeout=TIMEOUT_MINUTES,
cli_flags=GEMINI_FLAGS,
output_format="json",
),
call_ai_cli(
prompt="What color is the sky?",
ai_provider="cursor",
ai_model=CURSOR_MODEL,
ai_cli_timeout=TIMEOUT_MINUTES,
cli_flags=CURSOR_FLAGS,
output_format="json",
),
)
for result in results:
provider = result.usage.provider if result.usage else "unknown"
model = result.usage.model if result.usage else "unknown"
prefix = f"[{provider}/{model}]"
if result.success:
print(f"{prefix} {result.text}")
if result.usage:
print(f"{prefix} Tokens: in={result.usage.input_tokens} out={result.usage.output_tokens}")
else:
print(f"{prefix} ERROR: {result.text}")
if __name__ == "__main__":
asyncio.run(main())