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)


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
148
149
150
151
# File 'lib/vellum_ai.rb', line 117

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)
  @uploaded_files = Vellum::UploadedFilesClient.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:



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

def ad_hoc
  @ad_hoc
end

#container_imagesVellum::ContainerImagesClient (readonly)



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

def container_images
  @container_images
end

#deploymentsVellum::DeploymentsClient (readonly)



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

def deployments
  @deployments
end

#document_indexesVellum::DocumentIndexesClient (readonly)



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

def document_indexes
  @document_indexes
end

#documentsVellum::DocumentsClient (readonly)



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

def documents
  @documents
end

#environmentsVellum::EnvironmentsClient (readonly)



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

def environments
  @environments
end

#eventsVellum::EventsClient (readonly)



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

def events
  @events
end

#folder_entitiesVellum::FolderEntitiesClient (readonly)



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

def folder_entities
  @folder_entities
end

#integration_auth_configsVellum::IntegrationAuthConfigsClient (readonly)



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

def integration_auth_configs
  @integration_auth_configs
end

#integration_providersVellum::IntegrationProvidersClient (readonly)



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

def integration_providers
  @integration_providers
end

#integrationsVellum::IntegrationsClient (readonly)



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

def integrations
  @integrations
end

#metric_definitionsVellum::MetricDefinitionsClient (readonly)



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

def metric_definitions
  @metric_definitions
end

#ml_modelsVellum::MlModelsClient (readonly)



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

def ml_models
  @ml_models
end

#organizationsVellum::OrganizationsClient (readonly)



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

def organizations
  @organizations
end

#promptsVellum::PromptsClient (readonly)



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

def prompts
  @prompts
end

#sandboxesVellum::SandboxesClient (readonly)



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

def sandboxes
  @sandboxes
end

#test_suite_runsVellum::TestSuiteRunsClient (readonly)



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

def test_suite_runs
  @test_suite_runs
end

#test_suitesVellum::TestSuitesClient (readonly)



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

def test_suites
  @test_suites
end

#uploaded_filesVellum::UploadedFilesClient (readonly)



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

def uploaded_files
  @uploaded_files
end

#workflow_deploymentsVellum::WorkflowDeploymentsClient (readonly)



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

def workflow_deployments
  @workflow_deployments
end

#workflow_executionsVellum::WorkflowExecutionsClient (readonly)



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

def workflow_executions
  @workflow_executions
end

#workflow_sandboxesVellum::WorkflowSandboxesClient (readonly)



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

def workflow_sandboxes
  @workflow_sandboxes
end

#workflowsVellum::WorkflowsClient (readonly)



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

def workflows
  @workflows
end

#workspace_secretsVellum::WorkspaceSecretsClient (readonly)



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

def workspace_secrets
  @workspace_secrets
end

#workspacesVellum::WorkspacesClient (readonly)



107
108
109
# File 'lib/vellum_ai.rb', line 107

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”)



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/vellum_ai.rb', line 166

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

)



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/vellum_ai.rb', line 211

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” }])



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/vellum_ai.rb', line 275

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” }])



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/vellum_ai.rb', line 329

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” } }])



374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/vellum_ai.rb', line 374

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”)



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/vellum_ai.rb', line 424

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: [{ }, { }])



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/vellum_ai.rb', line 467

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” }])



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/vellum_ai.rb', line 507

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