You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
selected_outputs=["agent1.content"] # Use blockName.attribute format
621
621
)
@@ -758,4 +758,15 @@ Configure the client using environment variables:
758
758
759
759
## License
760
760
761
-
Apache-2.0
761
+
Apache-2.0
762
+
763
+
import { FAQ } from'@/components/ui/faq'
764
+
765
+
<FAQitems={[
766
+
{ question: "Do I need to deploy a workflow before I can execute it via the SDK?", answer: "Yes. Workflows must be deployed before they can be executed through the SDK. You can use the validate_workflow() method to check whether a workflow is deployed and ready. If it returns False, deploy the workflow from the Sim UI first and create or select an API key during deployment." },
767
+
{ question: "What is the difference between sync and async execution?", answer: "Sync execution (the default) blocks until the workflow completes and returns the full result. Async execution (async_execution=True) returns immediately with a task ID that you can poll using get_job_status(). Use async mode for long-running workflows to avoid request timeouts. Async job statuses include queued, processing, completed, failed, and cancelled." },
768
+
{ question: "How does the SDK handle rate limiting?", answer: "The SDK provides built-in rate limiting support through the execute_with_retry() method. It uses exponential backoff (1s, 2s, 4s, 8s...) with 25% jitter to avoid thundering herd problems. If the API returns a retry-after header, that value is used instead. You can configure max_retries, initial_delay, max_delay, and backoff_multiplier. Use get_rate_limit_info() to check your current rate limit status." },
769
+
{ question: "Can I use the Python SDK as a context manager?", answer: "Yes. The SimStudioClient supports Python's context manager protocol. Use it with the 'with' statement to automatically close the underlying HTTP session when you are done, which is especially useful for scripts that create and discard client instances." },
770
+
{ question: "How do I handle different types of errors from the SDK?", answer: "The SDK raises SimStudioError with a code property for API-specific errors. Common error codes are UNAUTHORIZED (invalid API key), TIMEOUT (request timed out), RATE_LIMIT_EXCEEDED (too many requests), USAGE_LIMIT_EXCEEDED (billing limit reached), and EXECUTION_ERROR (workflow failed). Use the error code to implement targeted error handling and recovery logic." },
771
+
{ question: "How do I monitor my API usage and remaining quota?", answer: "Use the get_usage_limits() method to check your current usage. It returns sync and async rate limit details (limit, remaining, reset time, whether you are currently limited), plus your current period cost, usage limit, and plan tier. This lets you monitor consumption and alert before hitting limits." },
@@ -774,8 +762,7 @@ const client = new SimStudioClient({
774
762
asyncfunction executeAsync() {
775
763
try {
776
764
// Start async execution
777
-
const result =awaitclient.executeWorkflow('workflow-id', {
778
-
input: { data: 'large dataset' },
765
+
const result =awaitclient.executeWorkflow('workflow-id', { data: 'large dataset' }, {
779
766
async: true// Execute asynchronously
780
767
});
781
768
@@ -823,9 +810,7 @@ const client = new SimStudioClient({
823
810
asyncfunction executeWithRetryHandling() {
824
811
try {
825
812
// Automatically retries on rate limit
826
-
const result =awaitclient.executeWithRetry('workflow-id', {
827
-
input: { message: 'Process this' }
828
-
}, {
813
+
const result =awaitclient.executeWithRetry('workflow-id', { message: 'Process this' }, {}, {
829
814
maxRetries: 5,
830
815
initialDelay: 1000,
831
816
maxDelay: 60000,
@@ -908,8 +893,7 @@ const client = new SimStudioClient({
908
893
asyncfunction executeWithStreaming() {
909
894
try {
910
895
// Enable streaming for specific block outputs
911
-
const result =awaitclient.executeWorkflow('workflow-id', {
912
-
input: { message: 'Count to five' },
896
+
const result =awaitclient.executeWorkflow('workflow-id', { message: 'Count to five' }, {
913
897
stream: true,
914
898
selectedOutputs: ['agent1.content'] // Use blockName.attribute format
915
899
});
@@ -1033,3 +1017,14 @@ function StreamingWorkflow() {
1033
1017
## License
1034
1018
1035
1019
Apache-2.0
1020
+
1021
+
import { FAQ } from'@/components/ui/faq'
1022
+
1023
+
<FAQitems={[
1024
+
{ question: "Do I need to deploy a workflow before I can execute it via the SDK?", answer: "Yes. Workflows must be deployed before they can be executed through the SDK. You can use the validateWorkflow() method to check whether a workflow is deployed and ready. If it returns false, deploy the workflow from the Sim UI first and create or select an API key during deployment." },
1025
+
{ question: "What is the difference between sync and async execution?", answer: "Sync execution (the default) blocks until the workflow completes and returns the full result. Async execution returns immediately with a task ID that you can poll using getJobStatus(). Use async mode for long-running workflows to avoid request timeouts. Async job statuses include queued, processing, completed, failed, and cancelled." },
1026
+
{ question: "How does streaming work with the SDK?", answer: "Enable streaming by setting stream: true and specifying selectedOutputs with block names and attributes in blockName.attribute format (e.g., ['agent1.content']). The response uses Server-Sent Events (SSE) format, sending incremental chunks as the workflow executes. Each chunk includes the blockId and the text content. A final done event includes the execution metadata." },
1027
+
{ question: "How does the SDK handle rate limiting?", answer: "The SDK provides built-in rate limiting support through the executeWithRetry() method. It uses exponential backoff (1s, 2s, 4s, 8s...) with 25% jitter to avoid thundering herd problems. If the API returns a retry-after header, that value is used instead. You can configure maxRetries, initialDelay, maxDelay, and backoffMultiplier. Use getRateLimitInfo() to check your current rate limit status." },
1028
+
{ question: "Is it safe to use the SDK in browser-side code?", answer: "You can use the SDK in the browser, but you should not expose your API key in client-side code. In production, use a backend proxy server to handle SDK calls, or use a public API key with limited permissions. The SDK works with both Node.js and browser environments, but sensitive keys should stay server-side." },
1029
+
{ question: "How do I send files to a workflow through the SDK?", answer: "File objects are automatically detected and converted to base64 format. Include them in the input object under the field name that matches your workflow's API trigger input format. In the browser, pass File objects directly from file inputs. In Node.js, create File objects from buffers. You can also provide files as URL references with type, data, name, and mime fields." },
0 commit comments