Class: Vellum::AsyncClient

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::AsyncClient

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)


589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
# File 'lib/vellum_ai.rb', line 589

def initialize(base_url: nil, environment: Vellum::Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil, api_key:, api_version: nil)
  @async_request_client = Vellum::AsyncRequestClient.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::AsyncIntegrationsClient.new(request_client: @async_request_client)
  @events = Vellum::AsyncEventsClient.new(request_client: @async_request_client)
  @ad_hoc = Vellum::AsyncAdHocClient.new(request_client: @async_request_client)
  @container_images = Vellum::AsyncContainerImagesClient.new(request_client: @async_request_client)
  @deployments = Vellum::AsyncDeploymentsClient.new(request_client: @async_request_client)
  @document_indexes = Vellum::AsyncDocumentIndexesClient.new(request_client: @async_request_client)
  @documents = Vellum::AsyncDocumentsClient.new(request_client: @async_request_client)
  @environments = Vellum::AsyncEnvironmentsClient.new(request_client: @async_request_client)
  @folder_entities = Vellum::AsyncFolderEntitiesClient.new(request_client: @async_request_client)
  @integration_auth_configs = Vellum::AsyncIntegrationAuthConfigsClient.new(request_client: @async_request_client)
  @integration_providers = Vellum::AsyncIntegrationProvidersClient.new(request_client: @async_request_client)
  @metric_definitions = Vellum::AsyncMetricDefinitionsClient.new(request_client: @async_request_client)
  @ml_models = Vellum::AsyncMlModelsClient.new(request_client: @async_request_client)
  @organizations = Vellum::AsyncOrganizationsClient.new(request_client: @async_request_client)
  @prompts = Vellum::AsyncPromptsClient.new(request_client: @async_request_client)
  @sandboxes = Vellum::AsyncSandboxesClient.new(request_client: @async_request_client)
  @test_suite_runs = Vellum::AsyncTestSuiteRunsClient.new(request_client: @async_request_client)
  @test_suites = Vellum::AsyncTestSuitesClient.new(request_client: @async_request_client)
  @uploaded_files = Vellum::AsyncUploadedFilesClient.new(request_client: @async_request_client)
  @workflow_deployments = Vellum::AsyncWorkflowDeploymentsClient.new(request_client: @async_request_client)
  @workflow_executions = Vellum::AsyncWorkflowExecutionsClient.new(request_client: @async_request_client)
  @workflow_sandboxes = Vellum::AsyncWorkflowSandboxesClient.new(request_client: @async_request_client)
  @workflows = Vellum::AsyncWorkflowsClient.new(request_client: @async_request_client)
  @workspace_secrets = Vellum::AsyncWorkspaceSecretsClient.new(request_client: @async_request_client)
  @workspaces = Vellum::AsyncWorkspacesClient.new(request_client: @async_request_client)
end

Instance Attribute Details

#ad_hocVellum::AsyncAdHocClient (readonly)



535
536
537
# File 'lib/vellum_ai.rb', line 535

def ad_hoc
  @ad_hoc
end

#container_imagesVellum::AsyncContainerImagesClient (readonly)



537
538
539
# File 'lib/vellum_ai.rb', line 537

def container_images
  @container_images
end

#deploymentsVellum::AsyncDeploymentsClient (readonly)



539
540
541
# File 'lib/vellum_ai.rb', line 539

def deployments
  @deployments
end

#document_indexesVellum::AsyncDocumentIndexesClient (readonly)



541
542
543
# File 'lib/vellum_ai.rb', line 541

def document_indexes
  @document_indexes
end

#documentsVellum::AsyncDocumentsClient (readonly)



543
544
545
# File 'lib/vellum_ai.rb', line 543

def documents
  @documents
end

#environmentsVellum::AsyncEnvironmentsClient (readonly)



545
546
547
# File 'lib/vellum_ai.rb', line 545

def environments
  @environments
end

#eventsVellum::AsyncEventsClient (readonly)



533
534
535
# File 'lib/vellum_ai.rb', line 533

def events
  @events
end

#folder_entitiesVellum::AsyncFolderEntitiesClient (readonly)



547
548
549
# File 'lib/vellum_ai.rb', line 547

def folder_entities
  @folder_entities
end

#integration_auth_configsVellum::AsyncIntegrationAuthConfigsClient (readonly)



549
550
551
# File 'lib/vellum_ai.rb', line 549

def integration_auth_configs
  @integration_auth_configs
end

#integration_providersVellum::AsyncIntegrationProvidersClient (readonly)



551
552
553
# File 'lib/vellum_ai.rb', line 551

def integration_providers
  @integration_providers
end

#integrationsVellum::AsyncIntegrationsClient (readonly)



531
532
533
# File 'lib/vellum_ai.rb', line 531

def integrations
  @integrations
end

#metric_definitionsVellum::AsyncMetricDefinitionsClient (readonly)



553
554
555
# File 'lib/vellum_ai.rb', line 553

def metric_definitions
  @metric_definitions
end

#ml_modelsVellum::AsyncMlModelsClient (readonly)



555
556
557
# File 'lib/vellum_ai.rb', line 555

def ml_models
  @ml_models
end

#organizationsVellum::AsyncOrganizationsClient (readonly)



557
558
559
# File 'lib/vellum_ai.rb', line 557

def organizations
  @organizations
end

#promptsVellum::AsyncPromptsClient (readonly)



559
560
561
# File 'lib/vellum_ai.rb', line 559

def prompts
  @prompts
end

#sandboxesVellum::AsyncSandboxesClient (readonly)



561
562
563
# File 'lib/vellum_ai.rb', line 561

def sandboxes
  @sandboxes
end

#test_suite_runsVellum::AsyncTestSuiteRunsClient (readonly)



563
564
565
# File 'lib/vellum_ai.rb', line 563

def test_suite_runs
  @test_suite_runs
end

#test_suitesVellum::AsyncTestSuitesClient (readonly)



565
566
567
# File 'lib/vellum_ai.rb', line 565

def test_suites
  @test_suites
end

#uploaded_filesVellum::AsyncUploadedFilesClient (readonly)



567
568
569
# File 'lib/vellum_ai.rb', line 567

def uploaded_files
  @uploaded_files
end

#workflow_deploymentsVellum::AsyncWorkflowDeploymentsClient (readonly)



569
570
571
# File 'lib/vellum_ai.rb', line 569

def workflow_deployments
  @workflow_deployments
end

#workflow_executionsVellum::AsyncWorkflowExecutionsClient (readonly)



571
572
573
# File 'lib/vellum_ai.rb', line 571

def workflow_executions
  @workflow_executions
end

#workflow_sandboxesVellum::AsyncWorkflowSandboxesClient (readonly)



573
574
575
# File 'lib/vellum_ai.rb', line 573

def workflow_sandboxes
  @workflow_sandboxes
end

#workflowsVellum::AsyncWorkflowsClient (readonly)



575
576
577
# File 'lib/vellum_ai.rb', line 575

def workflows
  @workflows
end

#workspace_secretsVellum::AsyncWorkspaceSecretsClient (readonly)



577
578
579
# File 'lib/vellum_ai.rb', line 577

def workspace_secrets
  @workspace_secrets
end

#workspacesVellum::AsyncWorkspacesClient (readonly)



579
580
581
# File 'lib/vellum_ai.rb', line 579

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



638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'lib/vellum_ai.rb', line 638

def execute_api(url:, method: nil, body: nil, headers: nil, bearer_token: nil, request_options: nil)
  response = @async_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 || {}), **@async_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 "#{@async_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

)



683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/vellum_ai.rb', line 683

def execute_code(code:, runtime:, input_values:, packages:, output_type:, request_options: nil)
  response = @async_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 || {}), **@async_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 "#{@async_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” }])



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
# File 'lib/vellum_ai.rb', line 747

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 = @async_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 || {}), **@async_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 "#{@async_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” }])



801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
# File 'lib/vellum_ai.rb', line 801

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 = @async_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 || {}), **@async_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 "#{@async_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” } }])



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# File 'lib/vellum_ai.rb', line 846

def generate(deployment_id: nil, deployment_name: nil, requests:, options: nil, request_options: nil)
  response = @async_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 || {}), **@async_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 "#{@async_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”)



896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'lib/vellum_ai.rb', line 896

def search(index_id: nil, index_name: nil, query:, options: nil, document_index: nil, request_options: nil)
  response = @async_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 || {}), **@async_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 "#{@async_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: [{ }, { }])



939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
# File 'lib/vellum_ai.rb', line 939

def submit_completion_actuals(deployment_id: nil, deployment_name: nil, actuals:, request_options: nil)
  response = @async_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 || {}), **@async_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 "#{@async_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” }])



979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
# File 'lib/vellum_ai.rb', line 979

def submit_workflow_execution_actuals(actuals:, execution_id: nil, external_id: nil, request_options: nil)
  response = @async_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 || {}), **@async_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 "#{@async_request_client.get_url(environment: Predict, request_options: request_options)}/v1/submit-workflow-execution-actuals"
end
end