MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / main

Function main

examples/components/openai/main.cpp:5–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <ai/ai.h>
4
5int main() {
6 std::cout << "AI SDK C++ - OpenAI Component Demo\n";
7 std::cout << "==================================\n\n";
8
9 std::cout << "Available components:\n";
10 std::cout << "- Core: YES\n";
11
12#ifdef AI_SDK_HAS_OPENAI
13 std::cout << "- OpenAI: YES\n";
14#else
15 std::cout << "- OpenAI: NO\n";
16#endif
17
18#ifdef AI_SDK_HAS_ANTHROPIC
19 std::cout << "- Anthropic: YES\n";
20#else
21 std::cout << "- Anthropic: NO\n";
22#endif
23
24 std::cout << "\n";
25
26 // Test core functionality
27 std::cout << "Testing core functionality...\n";
28 ai::GenerateOptions options;
29 options.model = "gpt-5.4";
30 options.prompt = "Hello world";
31 std::cout << "✓ Core types work fine\n\n";
32
33 // Test OpenAI functionality
34#ifdef AI_SDK_HAS_OPENAI
35 std::cout << "Testing OpenAI functionality...\n";
36 try {
37 auto client = ai::openai::create_client();
38 std::cout << "✓ OpenAI client created successfully\n";
39 std::cout << "✓ Available models: " << ai::openai::models::kGpt54 << ", "
40 << ai::openai::models::kGpt54Mini << "\n";
41 } catch (const std::exception& e) {
42 std::cout << "✗ OpenAI client failed: " << e.what() << "\n";
43 }
44#else
45 std::cout << "OpenAI functionality not available\n";
46#endif
47
48 // Demonstrate that Anthropic is NOT available
49#ifdef AI_SDK_HAS_ANTHROPIC
50 std::cout << "\nTesting Anthropic functionality...\n";
51 // This would work if Anthropic was linked
52 auto anthropic_client = ai::anthropic::create_client();
53 std::cout << "✓ Anthropic client created\n";
54#else
55 std::cout << "\nAnthropie functionality intentionally not available in this "
56 "build\n";
57 std::cout << "This example only links ai::openai component\n";
58
59 // Uncommenting the next line would cause a compile error:
60 // auto anthropic_client = ai::anthropic::create_client(); // ERROR!
61#endif
62

Callers

nothing calls this directly

Calls 1

create_clientFunction · 0.50

Tested by

no test coverage detected