phaseo_sdk 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/index"
3
+
4
+ class PricingModelsTest < Minitest::Test
5
+ def test_list_pricing_models_returns_payload
6
+ client = PhaseoSdk::Phaseo.new(
7
+ api_key: "test",
8
+ enable_deprecation_warnings: false
9
+ )
10
+
11
+ calls = []
12
+ client.raw_client.define_singleton_method(:request) do |method:, path:, query: nil, headers: nil, body: nil|
13
+ calls << [method, path, query, headers, body]
14
+ {
15
+ "ok" => true,
16
+ "models" => [
17
+ {
18
+ "provider" => "openai",
19
+ "model" => "openai/gpt-5-mini",
20
+ "endpoint" => "responses",
21
+ "display_name" => "GPT-5 Mini",
22
+ "meters" => [
23
+ {
24
+ "meter" => "input_tokens",
25
+ "unit" => "tokens",
26
+ "unit_size" => 1000,
27
+ "price_per_unit" => "0.00025",
28
+ "currency" => "USD"
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ }
34
+ end
35
+
36
+ response = client.list_pricing_models("provider" => "openai")
37
+
38
+ assert_equal true, response["ok"]
39
+ assert_equal "openai", response["models"][0]["provider"]
40
+ assert_equal [["GET", "/pricing/models", { "provider" => "openai" }, nil, nil]], calls
41
+ end
42
+ end
@@ -0,0 +1,44 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/index"
3
+
4
+ class ProviderOpsTest < Minitest::Test
5
+ def test_provider_and_usage_helpers_return_payloads
6
+ client = PhaseoSdk::Phaseo.new(
7
+ api_key: "test",
8
+ enable_deprecation_warnings: false
9
+ )
10
+
11
+ calls = []
12
+ client.raw_client.define_singleton_method(:request) do |method:, path:, query: nil, headers: nil, body: nil|
13
+ calls << [method, path, query, headers, body]
14
+ case path
15
+ when "/providers"
16
+ { "ok" => true, "providers" => [{ "provider_id" => "openai", "name" => "OpenAI" }] }
17
+ when "/credits"
18
+ { "ok" => true, "credits" => { "balance_usd" => 42.5 } }
19
+ when "/activity"
20
+ { "ok" => true, "total" => 1, "activity" => [{ "request_id" => "req_123" }] }
21
+ when "/analytics"
22
+ { "data" => [{ "date" => "2026-05-01", "endpoint_id" => "responses", "requests" => 12 }] }
23
+ else
24
+ raise "Unexpected request"
25
+ end
26
+ end
27
+
28
+ providers = client.list_providers("limit" => "2")
29
+ credits = client.get_credits("team_id" => "team_123")
30
+ activity = client.get_activity("days" => "30")
31
+ analytics = client.get_analytics("date" => "2026-05-01")
32
+
33
+ assert_equal "openai", providers["providers"][0]["provider_id"]
34
+ assert_equal 42.5, credits["credits"]["balance_usd"]
35
+ assert_equal "req_123", activity["activity"][0]["request_id"]
36
+ assert_equal "responses", analytics["data"][0]["endpoint_id"]
37
+ assert_equal [
38
+ ["GET", "/providers", { "limit" => "2" }, nil, nil],
39
+ ["GET", "/credits", { "team_id" => "team_123" }, nil, nil],
40
+ ["GET", "/activity", { "days" => "30" }, nil, nil],
41
+ ["GET", "/analytics", { "date" => "2026-05-01" }, nil, nil]
42
+ ], calls
43
+ end
44
+ end
@@ -0,0 +1,22 @@
1
+ require "json"
2
+ require_relative "../src/gen/client"
3
+ require_relative "../src/gen/operations"
4
+
5
+ api_key = ENV["PHASEO_API_KEY"]
6
+ raise "PHASEO_API_KEY is required" if api_key.nil? || api_key.empty?
7
+
8
+ base_url = ENV["PHASEO_BASE_URL"] || "https://api.phaseo.app/v1"
9
+ model = ENV["PHASEO_SMOKE_MODEL"] || "openai/gpt-5.4-nano"
10
+ input = ENV["PHASEO_SMOKE_INPUT"] || "Hi"
11
+
12
+ client = Phaseo::Gen::Client.new(base_url: base_url, headers: { "Authorization" => "Bearer #{api_key}" })
13
+
14
+ response = Phaseo::Gen::Operations.createChatCompletion(
15
+ client,
16
+ body: {
17
+ model: model,
18
+ messages: [{ role: "user", content: input }]
19
+ }
20
+ )
21
+
22
+ puts JSON.pretty_generate(response)
@@ -0,0 +1,25 @@
1
+ require "json"
2
+ require_relative "../src/gen/client"
3
+ require_relative "../src/gen/operations"
4
+
5
+ api_key = ENV["PHASEO_API_KEY"]
6
+ raise "PHASEO_API_KEY is required" if api_key.nil? || api_key.empty?
7
+
8
+ base_url = ENV["PHASEO_BASE_URL"] || "https://api.phaseo.app/v1"
9
+ model = ENV["PHASEO_SMOKE_MODEL"] || "openai/gpt-5.4-nano"
10
+ input = ENV["PHASEO_SMOKE_INPUT"] || "Hi"
11
+ max_output_tokens = (ENV["PHASEO_SMOKE_MAX_OUTPUT_TOKENS"] || "32").to_i
12
+ max_output_tokens = 32 if max_output_tokens <= 0
13
+
14
+ client = Phaseo::Gen::Client.new(base_url: base_url, headers: { "Authorization" => "Bearer #{api_key}" })
15
+
16
+ response = Phaseo::Gen::Operations.createResponse(
17
+ client,
18
+ body: {
19
+ model: model,
20
+ input: input,
21
+ max_output_tokens: max_output_tokens
22
+ }
23
+ )
24
+
25
+ puts JSON.pretty_generate(response)
@@ -0,0 +1,30 @@
1
+ require "json"
2
+ require_relative "../lib/index"
3
+
4
+ api_key = ENV["PHASEO_API_KEY"]
5
+ raise "PHASEO_API_KEY is required" if api_key.nil? || api_key.empty?
6
+
7
+ base_url = ENV["PHASEO_BASE_URL"] || "https://api.phaseo.app/v1"
8
+ model = ENV["PHASEO_SMOKE_MODEL"] || "openai/gpt-5.4-nano"
9
+ input = ENV["PHASEO_SMOKE_INPUT"] || "Hi"
10
+ max_output_tokens = (ENV["PHASEO_SMOKE_MAX_OUTPUT_TOKENS"] || "32").to_i
11
+ max_output_tokens = 32 if max_output_tokens <= 0
12
+
13
+ client = PhaseoSdk::Phaseo.new(
14
+ api_key: api_key,
15
+ base_path: base_url,
16
+ enable_deprecation_warnings: false,
17
+ devtools: PhaseoSdk::Devtools.create
18
+ )
19
+
20
+ response = client.create_response(
21
+ model: model,
22
+ input: input,
23
+ max_output_tokens: max_output_tokens
24
+ )
25
+
26
+ unless response.is_a?(Hash) && !response["id"].to_s.empty?
27
+ raise "Expected response hash with id, got #{response.class}"
28
+ end
29
+
30
+ puts JSON.pretty_generate(response)
@@ -0,0 +1,152 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/index"
3
+
4
+ class VideoTest < Minitest::Test
5
+ def test_retrieve_video_content_returns_bytes
6
+ client = PhaseoSdk::Phaseo.new(
7
+ api_key: "test",
8
+ enable_deprecation_warnings: false
9
+ )
10
+
11
+ calls = []
12
+ client.raw_client.define_singleton_method(:request_bytes) do |method:, path:, query: nil, headers: nil, body: nil|
13
+ calls << [method, path, query, headers, body]
14
+ "video-bytes"
15
+ end
16
+
17
+ content = client.retrieve_video_content("video_123")
18
+
19
+ assert_equal "video-bytes", content
20
+ assert_equal [["get", "/videos/video_123/content", nil, nil, nil]], calls
21
+ end
22
+
23
+ def test_get_video_download_url_returns_payload
24
+ client = PhaseoSdk::Phaseo.new(
25
+ api_key: "test",
26
+ enable_deprecation_warnings: false
27
+ )
28
+
29
+ calls = []
30
+ client.raw_client.define_singleton_method(:request) do |method:, path:, query: nil, headers: nil, body: nil|
31
+ calls << [method, path, query, headers, body]
32
+ {
33
+ "download_url" => "https://cdn.example.test/video.mp4",
34
+ "expires_at" => 1_723_000_000
35
+ }
36
+ end
37
+
38
+ response = client.get_video_download_url("video_123", { disposition: "attachment" })
39
+
40
+ assert_equal "https://cdn.example.test/video.mp4", response["download_url"]
41
+ assert_equal 1_723_000_000, response["expires_at"]
42
+ assert_equal [["POST", "/videos/video_123/download_url", nil, nil, { disposition: "attachment" }]], calls
43
+ end
44
+
45
+ def test_video_lifecycle_helpers_return_payloads
46
+ client = PhaseoSdk::Phaseo.new(
47
+ api_key: "test",
48
+ enable_deprecation_warnings: false
49
+ )
50
+
51
+ calls = []
52
+ client.raw_client.define_singleton_method(:request) do |method:, path:, query: nil, headers: nil, body: nil|
53
+ calls << [method, path, query, headers, body]
54
+ if method == "GET" && path == "/models"
55
+ next({
56
+ "models" => [
57
+ {
58
+ "model_id" => "google/veo-3",
59
+ "status" => "active"
60
+ }
61
+ ]
62
+ })
63
+ end
64
+ if method == "POST" && path == "/videos"
65
+ next({
66
+ "id" => "video_123",
67
+ "object" => "video",
68
+ "status" => "queued",
69
+ "provider" => "google",
70
+ "request_id" => "req_ruby_video_1",
71
+ "session_id" => "session_ruby_video_1",
72
+ "pricing_lines" => [
73
+ { "dimension" => "video_seconds", "units" => 8 }
74
+ ]
75
+ })
76
+ end
77
+ if method == "GET" && path == "/videos/video_123"
78
+ next({
79
+ "id" => "video_123",
80
+ "object" => "video",
81
+ "status" => "completed",
82
+ "provider" => "google",
83
+ "request_id" => "req_ruby_video_1",
84
+ "session_id" => "session_ruby_video_1",
85
+ "pricing_lines" => [
86
+ { "dimension" => "video_seconds", "units" => 8 }
87
+ ]
88
+ })
89
+ end
90
+ if method == "POST" && path == "/videos/video_123/cancel"
91
+ next({
92
+ "id" => "video_123",
93
+ "object" => "video",
94
+ "status" => "cancelled"
95
+ })
96
+ end
97
+ if method == "DELETE" && path == "/videos/video_123"
98
+ next({
99
+ "id" => "video_123",
100
+ "object" => "video",
101
+ "deleted" => true
102
+ })
103
+ end
104
+ if method == "GET" && path == "/videos"
105
+ next({
106
+ "object" => "list",
107
+ "data" => [
108
+ { "id" => "video_123", "status" => "queued" },
109
+ { "id" => "video_456", "status" => "completed" }
110
+ ]
111
+ })
112
+ end
113
+ {
114
+ "object" => "list",
115
+ "data" => [
116
+ { "id" => "google/veo-3" }
117
+ ]
118
+ }
119
+ end
120
+
121
+ created = client.generate_video({ model: "google/veo-3", prompt: "orbiting camera shot" })
122
+ retrieved = client.get_video("video_123")
123
+ cancelled = client.cancel_video("video_123")
124
+ deleted = client.delete_video("video_123")
125
+ models = client.list_video_models
126
+ list = client.list_videos({ status: "queued,completed", limit: "2" })
127
+
128
+ assert_equal "queued", created["status"]
129
+ assert_equal "google", created["provider"]
130
+ assert_equal "req_ruby_video_1", created["request_id"]
131
+ assert_equal "session_ruby_video_1", created["session_id"]
132
+ assert_equal 1, created["pricing_lines"].length
133
+ assert_equal "completed", retrieved["status"]
134
+ assert_equal "google", retrieved["provider"]
135
+ assert_equal "req_ruby_video_1", retrieved["request_id"]
136
+ assert_equal "session_ruby_video_1", retrieved["session_id"]
137
+ assert_equal "cancelled", cancelled["status"]
138
+ assert_equal true, deleted["deleted"]
139
+ assert_equal "google/veo-3", models["data"][0]["id"]
140
+ assert_equal "video_456", list["data"][1]["id"]
141
+ assert_equal "wss://api.phaseo.app/v1/async/video/video_123/ws?interval_ms=900", client.video_websocket_url("video_123", interval_ms: 900)
142
+ assert_equal [
143
+ ["GET", "/models", { "model_id" => "google/veo-3", "limit" => "1" }, nil, nil],
144
+ ["POST", "/videos", nil, nil, { model: "google/veo-3", prompt: "orbiting camera shot" }],
145
+ ["GET", "/videos/video_123", nil, nil, nil],
146
+ ["POST", "/videos/video_123/cancel", nil, nil, nil],
147
+ ["DELETE", "/videos/video_123", nil, nil, nil],
148
+ ["GET", "/videos/models", nil, nil, nil],
149
+ ["GET", "/videos", { status: "queued,completed", limit: "2" }, nil, nil]
150
+ ], calls
151
+ end
152
+ end
@@ -0,0 +1,39 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/index"
3
+
4
+ class WorkspaceMutationsTest < Minitest::Test
5
+ def test_workspace_mutation_helpers_return_payloads
6
+ client = PhaseoSdk::Phaseo.new(
7
+ api_key: "test",
8
+ enable_deprecation_warnings: false
9
+ )
10
+
11
+ calls = []
12
+ client.raw_client.define_singleton_method(:request) do |method:, path:, query: nil, headers: nil, body: nil|
13
+ calls << [method, path, query, headers, body]
14
+ case [method, path]
15
+ when ["POST", "/workspaces"]
16
+ { "data" => { "id" => "ws_123", "slug" => "sandbox", "name" => "Sandbox Workspace" } }
17
+ when ["PATCH", "/workspaces/ws_123"]
18
+ { "data" => { "id" => "ws_123", "slug" => "sandbox", "name" => "Renamed Workspace", "archived" => true } }
19
+ when ["DELETE", "/workspaces/ws_123"]
20
+ { "data" => { "id" => "ws_123", "deleted" => true } }
21
+ else
22
+ raise "Unexpected request"
23
+ end
24
+ end
25
+
26
+ created = client.create_workspace("name" => "Sandbox Workspace", "slug" => "sandbox")
27
+ updated = client.update_workspace("ws_123", "name" => "Renamed Workspace", "archived" => true)
28
+ deleted = client.delete_workspace("ws_123")
29
+
30
+ assert_equal "sandbox", created["data"]["slug"]
31
+ assert_equal true, updated["data"]["archived"]
32
+ assert_equal true, deleted["data"]["deleted"]
33
+ assert_equal [
34
+ ["POST", "/workspaces", nil, nil, { "name" => "Sandbox Workspace", "slug" => "sandbox" }],
35
+ ["PATCH", "/workspaces/ws_123", nil, nil, { "name" => "Renamed Workspace", "archived" => true }],
36
+ ["DELETE", "/workspaces/ws_123", nil, nil, nil]
37
+ ], calls
38
+ end
39
+ end
@@ -0,0 +1,45 @@
1
+ require "minitest/autorun"
2
+ require_relative "../lib/index"
3
+
4
+ class WorkspacesTest < Minitest::Test
5
+ def test_list_and_get_workspaces_return_payloads
6
+ client = PhaseoSdk::Phaseo.new(
7
+ api_key: "test",
8
+ enable_deprecation_warnings: false
9
+ )
10
+
11
+ calls = []
12
+ client.raw_client.define_singleton_method(:request) do |method:, path:, query: nil, headers: nil, body: nil|
13
+ calls << [method, path, query, headers, body]
14
+ if path == "/workspaces"
15
+ {
16
+ "object" => "list",
17
+ "data" => [
18
+ { "id" => "ws_123", "slug" => "default" },
19
+ { "id" => "ws_456", "slug" => "sandbox" }
20
+ ]
21
+ }
22
+ else
23
+ {
24
+ "data" => {
25
+ "id" => "ws_123",
26
+ "slug" => "default",
27
+ "name" => "Default Workspace"
28
+ }
29
+ }
30
+ end
31
+ end
32
+
33
+ listed = client.list_workspaces("limit" => "2", "offset" => "3")
34
+ retrieved = client.get_workspace("ws_123")
35
+
36
+ assert_equal "list", listed["object"]
37
+ assert_equal "sandbox", listed["data"][1]["slug"]
38
+ assert_equal "ws_123", retrieved["data"]["id"]
39
+ assert_equal "Default Workspace", retrieved["data"]["name"]
40
+ assert_equal [
41
+ ["GET", "/workspaces", { "limit" => "2", "offset" => "3" }, nil, nil],
42
+ ["GET", "/workspaces/ws_123", nil, nil, nil]
43
+ ], calls
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phaseo_sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Phaseo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-07-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for the Phaseo Gateway API with generated endpoints and typed
14
+ wrappers.
15
+ email:
16
+ - danielbutler500@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - examples/models.rb
23
+ - lib/gen/client.rb
24
+ - lib/gen/models.rb
25
+ - lib/gen/operations.rb
26
+ - lib/index.rb
27
+ - lib/phaseo_sdk.rb
28
+ - lib/phaseo_sdk/model_ids.rb
29
+ - lib/phaseo_sdk/version.rb
30
+ - phaseo_sdk.gemspec
31
+ - tests/api_key_mutations_test.rb
32
+ - tests/api_key_test.rb
33
+ - tests/api_keys_test.rb
34
+ - tests/async_jobs_test.rb
35
+ - tests/batches_test.rb
36
+ - tests/chat_test.rb
37
+ - tests/current_key_test.rb
38
+ - tests/devtools_test.rb
39
+ - tests/endpoints_test.rb
40
+ - tests/files_test.rb
41
+ - tests/generation_test.rb
42
+ - tests/health_test.rb
43
+ - tests/lifecycle_test.rb
44
+ - tests/models_test.rb
45
+ - tests/organisations_test.rb
46
+ - tests/pricing_calculate_test.rb
47
+ - tests/pricing_models_test.rb
48
+ - tests/provider_ops_test.rb
49
+ - tests/smoke_chat.rb
50
+ - tests/smoke_responses.rb
51
+ - tests/smoke_responses_sdk.rb
52
+ - tests/video_test.rb
53
+ - tests/workspace_mutations_test.rb
54
+ - tests/workspaces_test.rb
55
+ homepage: https://phaseo.app
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://phaseo.app
60
+ source_code_uri: https://github.com/phaseoteam/Phaseo
61
+ changelog_uri: https://github.com/phaseoteam/Phaseo/blob/main/packages/sdk/sdk-ruby/CHANGELOG.md
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.0.0
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.4.19
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Official Phaseo Gateway SDK for Ruby
81
+ test_files: []