Class: Vellum::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, environment: Vellum::Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, api_key:, api_version: nil) ⇒ Vellum::Client

Parameters:

  • base_url (String) (defaults to: nil)
  • environment (Vellum::Environment) (defaults to: Vellum::Environment::PRODUCTION)
  • max_retries (Long) (defaults to: nil)

    The number of times to retry a failed request, defaults to 2.

  • timeout_in_seconds (Long) (defaults to: nil)
  • api_key (String)
  • api_version (Vellum::ApiVersionEnum) (defaults to: nil)


114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/vellum_ai.rb', line 114

def initialize(base_url: nil, environment: Vellum::Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, api_key:, api_version: nil)
  @request_client = Vellum::RequestClient.new(
  base_url: base_url,
  environment: environment,
  max_retries: max_retries,
  timeout_in_seconds: timeout_in_seconds,
  api_key: api_key,
  api_version: api_version
)
  @integrations = Vellum::IntegrationsClient.new(request_client: @request_client)
  @events = Vellum::EventsClient.new(request_client: @request_client)
  @ad_hoc = Vellum::AdHocClient.new(request_client: @request_client)
  @container_images = Vellum::ContainerImagesClient.new(request_client: @request_client)
  @deployments = Vellum::DeploymentsClient.new(request_client: @request_client)
  @document_indexes = Vellum::DocumentIndexesClient.new(request_client: @request_client)
  @documents = Vellum::DocumentsClient.new(request_client: @request_client)
  @environments = Vellum::EnvironmentsClient.new(request_client: @request_client)
  @folder_entities = Vellum::FolderEntitiesClient.new(request_client: @request_client)
  @integration_auth_configs = Vellum::IntegrationAuthConfigsClient.new(request_client: @request_client)
  @integration_providers = Vellum::IntegrationProvidersClient.new(request_client: @request_client)
  @metric_definitions = Vellum::MetricDefinitionsClient.new(request_client: @request_client)
  @ml_models = Vellum::MlModelsClient.new(request_client: @request_client)
  @organizations = Vellum::OrganizationsClient.new(request_client: @request_client)
  @prompts = Vellum::PromptsClient.new(request_client: @request_client)
  @sandboxes = Vellum::SandboxesClient.new(request_client: @request_client)
  @test_suite_runs = Vellum::TestSuiteRunsClient.new(request_client: @request_client)
  @test_suites = Vellum::TestSuitesClient.new(request_client: @request_client)
  @workflow_deployments = Vellum::WorkflowDeploymentsClient.new(request_client: @request_client)
  @workflow_executions = Vellum::WorkflowExecutionsClient.new(request_client: @request_client)
  @workflow_sandboxes = Vellum::WorkflowSandboxesClient.new(request_client: @request_client)
  @workflows = Vellum::WorkflowsClient.new(request_client: @request_client)
  @workspace_secrets = Vellum::WorkspaceSecretsClient.new(request_client: @request_client)
  @workspaces = Vellum::WorkspacesClient.new(request_client: @request_client)
end

Instance Attribute Details

#ad_hocVellum::AdHocClient (readonly)

Returns:



62
63
64
# File 'lib/vellum_ai.rb', line 62

def ad_hoc
  @ad_hoc
end

#container_imagesVellum::ContainerImagesClient (readonly)



64
65
66
# File 'lib/vellum_ai.rb', line 64

def container_images
  @container_images
end

#deploymentsVellum::DeploymentsClient (readonly)



66
67
68
# File 'lib/vellum_ai.rb', line 66

def deployments
  @deployments
end

#document_indexesVellum::DocumentIndexesClient (readonly)



68
69
70
# File 'lib/vellum_ai.rb', line 68

def document_indexes
  @document_indexes
end

#documentsVellum::DocumentsClient (readonly)



70
71
72
# File 'lib/vellum_ai.rb', line 70

def documents
  @documents
end

#environmentsVellum::EnvironmentsClient (readonly)



72
73
74
# File 'lib/vellum_ai.rb', line 72

def environments
  @environments
end

#eventsVellum::EventsClient (readonly)



60
61
62
# File 'lib/vellum_ai.rb', line 60

def events
  @events
end

#folder_entitiesVellum::FolderEntitiesClient (readonly)



74
75
76
# File 'lib/vellum_ai.rb', line 74

def folder_entities
  @folder_entities
end

#integration_auth_configsVellum::IntegrationAuthConfigsClient (readonly)



76
77
78
# File 'lib/vellum_ai.rb', line 76

def integration_auth_configs
  @integration_auth_configs
end

#integration_providersVellum::IntegrationProvidersClient (readonly)



78
79
80
# File 'lib/vellum_ai.rb', line 78

def integration_providers
  @integration_providers
end

#integrationsVellum::IntegrationsClient (readonly)



58
59
60
# File 'lib/vellum_ai.rb', line 58

def integrations
  @integrations
end

#metric_definitionsVellum::MetricDefinitionsClient (readonly)



80
81
82
# File 'lib/vellum_ai.rb', line 80

def metric_definitions
  @metric_definitions
end

#ml_modelsVellum::MlModelsClient (readonly)



82
83
84
# File 'lib/vellum_ai.rb', line 82

def ml_models
  @ml_models
end

#organizationsVellum::OrganizationsClient (readonly)



84
85
86
# File 'lib/vellum_ai.rb', line 84

def organizations
  @organizations
end

#promptsVellum::PromptsClient (readonly)



86
87
88
# File 'lib/vellum_ai.rb', line 86

def prompts
  @prompts
end

#sandboxesVellum::SandboxesClient (readonly)



88
89
90
# File 'lib/vellum_ai.rb', line 88

def sandboxes
  @sandboxes
end

#test_suite_runsVellum::TestSuiteRunsClient (readonly)



90
91
92
# File 'lib/vellum_ai.rb', line 90

def test_suite_runs
  @test_suite_runs
end

#test_suitesVellum::TestSuitesClient (readonly)



92
93
94
# File 'lib/vellum_ai.rb', line 92

def test_suites
  @test_suites
end

#workflow_deploymentsVellum::WorkflowDeploymentsClient (readonly)



94
95
96
# File 'lib/vellum_ai.rb', line 94

def workflow_deployments
  @workflow_deployments
end

#workflow_executionsVellum::WorkflowExecutionsClient (readonly)



96
97
98
# File 'lib/vellum_ai.rb', line 96

def workflow_executions
  @workflow_executions
end

#workflow_sandboxesVellum::WorkflowSandboxesClient (readonly)



98
99
100
# File 'lib/vellum_ai.rb', line 98

def workflow_sandboxes
  @workflow_sandboxes
end

#workflowsVellum::WorkflowsClient (readonly)



100
101
102
# File 'lib/vellum_ai.rb', line 100

def workflows
  @workflows
end

#workspace_secretsVellum::WorkspaceSecretsClient (readonly)



102
103
104
# File 'lib/vellum_ai.rb', line 102

def workspace_secrets
  @workspace_secrets
end

#workspacesVellum::WorkspacesClient (readonly)



104
105
106
# File 'lib/vellum_ai.rb', line 104

def workspaces
  @workspaces
end

Instance Method Details

#execute_api(url:, method: nil, body: nil, headers: nil, bearer_token: nil, request_options: nil) ⇒ Object

api.execute_api(url: “x”)



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/vellum_ai.rb', line 162

def execute_api(url:, method: nil, body: nil, headers: nil, bearer_token: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), url: url, method: method, body: body, headers: headers, bearer_token: bearer_token }.compact
  req.url "#{@request_client.get_url(environment: Default, request_options: request_options)}/v1/execute-api"
end
  Vellum::ExecuteApiResponse.from_json(json_object: response.body)
end

#execute_code(code:, runtime:, input_values:, packages:, output_type:, request_options: nil) ⇒ Object

)



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/vellum_ai.rb', line 207

def execute_code(code:, runtime:, input_values:, packages:, output_type:, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), code: code, runtime: runtime, input_values: input_values, packages: packages, output_type: output_type }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/execute-code"
end
  Vellum::CodeExecutorResponse.from_json(json_object: response.body)
end

#execute_prompt(inputs:, prompt_deployment_id: nil, prompt_deployment_name: nil, release_tag: nil, external_id: nil, expand_meta: nil, raw_overrides: nil, expand_raw: nil, metadata: nil, request_options: nil) ⇒ Object

api.execute_prompt(inputs: [{ name: “x”, type: “STRING”, value: “value” }, { name: “x”, type: “STRING”, value: “value” }])



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/vellum_ai.rb', line 271

def execute_prompt(inputs:, prompt_deployment_id: nil, prompt_deployment_name: nil, release_tag: nil, external_id: nil, expand_meta: nil, raw_overrides: nil, expand_raw: nil, metadata: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), inputs: inputs, prompt_deployment_id: prompt_deployment_id, prompt_deployment_name: prompt_deployment_name, release_tag: release_tag, external_id: external_id, expand_meta: expand_meta, raw_overrides: raw_overrides, expand_raw: expand_raw, metadata:  }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/execute-prompt"
end
  Vellum::ExecutePromptResponse.from_json(json_object: response.body)
end

#execute_workflow(inputs:, expand_meta: nil, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil, external_id: nil, metadata: nil, previous_execution_id: nil, request_options: nil) ⇒ Object

api.execute_workflow(inputs: [{ name: “x”, type: “STRING”, value: “value” }, { name: “x”, type: “STRING”, value: “value” }])



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/vellum_ai.rb', line 325

def execute_workflow(inputs:, expand_meta: nil, workflow_deployment_id: nil, workflow_deployment_name: nil, release_tag: nil, external_id: nil, metadata: nil, previous_execution_id: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), inputs: inputs, expand_meta: expand_meta, workflow_deployment_id: workflow_deployment_id, workflow_deployment_name: workflow_deployment_name, release_tag: release_tag, external_id: external_id, metadata: , previous_execution_id: previous_execution_id }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/execute-workflow"
end
  Vellum::ExecuteWorkflowResponse.from_json(json_object: response.body)
end

#generate(deployment_id: nil, deployment_name: nil, requests:, options: nil, request_options: nil) ⇒ Object

api.generate(requests: [{ input_values: { “input_values”: “key”:“value” } }, { input_values: { “input_values”: “key”:“value” } }])



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/vellum_ai.rb', line 370

def generate(deployment_id: nil, deployment_name: nil, requests:, options: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), deployment_id: deployment_id, deployment_name: deployment_name, requests: requests, options: options }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/generate"
end
  Vellum::GenerateResponse.from_json(json_object: response.body)
end

#search(index_id: nil, index_name: nil, query:, options: nil, document_index: nil, request_options: nil) ⇒ Object

api.search(query: “x”)



420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/vellum_ai.rb', line 420

def search(index_id: nil, index_name: nil, query:, options: nil, document_index: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), index_id: index_id, index_name: index_name, query: query, options: options, document_index: document_index }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/search"
end
  Vellum::SearchResponse.from_json(json_object: response.body)
end

#submit_completion_actuals(deployment_id: nil, deployment_name: nil, actuals:, request_options: nil) ⇒ Object

api.submit_completion_actuals(actuals: [{ }, { }])



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/vellum_ai.rb', line 463

def submit_completion_actuals(deployment_id: nil, deployment_name: nil, actuals:, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), deployment_id: deployment_id, deployment_name: deployment_name, actuals: actuals }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/submit-completion-actuals"
end
end

#submit_workflow_execution_actuals(actuals:, execution_id: nil, external_id: nil, request_options: nil) ⇒ Object

api.submit_workflow_execution_actuals(actuals: [{ output_type: “STRING” }, { output_type: “STRING” }])



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'lib/vellum_ai.rb', line 503

def submit_workflow_execution_actuals(actuals:, execution_id: nil, external_id: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.api_key.nil?
req.headers["X-API-KEY"] = request_options.api_key
  end
  unless request_options&.api_version.nil?
req.headers["X-API-Version"] = request_options.api_version
  else
req.headers["X-API-Version"] = "2025-07-30"
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), actuals: actuals, execution_id: execution_id, external_id: external_id }.compact
  req.url "#{@request_client.get_url(environment: Predict, request_options: request_options)}/v1/submit-workflow-execution-actuals"
end
end