# Run Straico Prompt Completion V1

**Action ID:** `straico_prompt_completion`

## Description

Run a prompt completion using the Straico API.

## Connection

| Name               | Description                                  | Required | Category |
| ------------------ | -------------------------------------------- | -------- | -------- |
| Straico Connection | The Straico connection to use for the model. | True     | straico  |

## Input Schema

```json
{
  "description": "Run Straico prompt completion node input.",
  "properties": {
    "models": {
      "description": "An array of 1-4 unique model identifiers",
      "items": {
        "type": "string"
      },
      "maxItems": 4,
      "minItems": 1,
      "title": "Models",
      "type": "array"
    },
    "message": {
      "description": "The prompt text for which completions are requested",
      "title": "Message",
      "type": "string"
    },
    "file_urls": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "maxItems": 4,
          "minItems": 0,
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An array of up to 4 file URLs, previously uploaded via the File Upload endpoint",
      "title": "File URLs"
    },
    "images": {
      "default": [],
      "description": "An array of image URLs.",
      "items": {
        "type": "string"
      },
      "maxItems": 4,
      "minItems": 0,
      "title": "Images",
      "type": "array"
    },
    "youtube_urls": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "maxItems": 4,
          "minItems": 0,
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "An array of up to 4 YouTube video URLs",
      "title": "YouTube URLs"
    },
    "display_transcripts": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "If true, returns transcripts of the files. Default: false",
      "title": "Display Transcripts"
    },
    "temperature": {
      "default": 0,
      "description": "This setting influences the variety in the model's responses (0-2)",
      "maximum": 2,
      "minimum": 0,
      "title": "Temperature",
      "type": "number"
    },
    "max_tokens": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Set the limit for the number of tokens the model can generate in response",
      "title": "Max Tokens"
    }
  },
  "required": [
    "models",
    "message"
  ],
  "title": "StraicoPromptCompletionInput",
  "type": "object"
}
```

## Output Schema

```json
{
  "$defs": {
    "StraicoPromptCompletionData": {
      "description": "Output from a Straico prompt completion.",
      "properties": {
        "overall_price": {
          "additionalProperties": true,
          "description": "The overall price of the prompt completion.",
          "title": "Overall Price",
          "type": "object"
        },
        "overall_words": {
          "additionalProperties": true,
          "description": "Overall word count for all models, including input, output and total words.",
          "title": "Overall Words",
          "type": "object"
        },
        "completions": {
          "additionalProperties": true,
          "description": "Detailed results for each requested model.",
          "title": "Completions",
          "type": "object"
        },
        "transcripts": {
          "anyOf": [
            {
              "items": {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "If display_transcripts is true, returns an array of transcripts, each containing a name and text.",
          "title": "Transcripts"
        }
      },
      "required": [
        "overall_price",
        "overall_words",
        "completions"
      ],
      "title": "StraicoPromptCompletionData",
      "type": "object"
    }
  },
  "description": "Output from a Straico prompt completion.",
  "properties": {
    "data": {
      "anyOf": [
        {
          "$ref": "#/$defs/StraicoPromptCompletionData"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The data from the prompt completion.",
      "title": "Data"
    },
    "success": {
      "description": "Whether the prompt completion was successful.",
      "title": "Success",
      "type": "boolean"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "If the prompt completion was not successful, this will contain an error message.",
      "title": "Error"
    }
  },
  "required": [
    "success"
  ],
  "title": "StraicoPromptCompletionOutput",
  "type": "object"
}
```

## How It Works

This node sends your prompt to the Straico API, which can query 1-4 AI models simultaneously. The prompt, along with optional images, files, or YouTube URLs, is processed by each selected model. Straico handles the API routing, aggregates responses from all models, and returns completions along with pricing and word count metrics. This enables easy comparison of different model outputs in a single API call.

## Usage Examples

### Example 1: Simple Text Prompt with Single Model

**Input:**

```
models: ["gpt-4"]
message: "Explain quantum computing in simple terms"
temperature: 0.7
```

**Output:**

```
success: true
data:
  overall_price: {coins: 15, credits: 0.015}
  overall_words: {input: 6, output: 142, total: 148}
  completions:
    gpt-4:
      completion: "Quantum computing is a revolutionary approach..."
      model: "gpt-4"
      words: {input: 6, output: 142}
      price: {coins: 15, credits: 0.015}
```

### Example 2: Multi-Model Comparison with Image Analysis

**Input:**

```
models: ["gpt-4-vision", "claude-3-opus", "gemini-pro-vision"]
message: "Describe what you see in this image and identify the main objects"
images: ["https://example.com/product-photo.jpg"]
temperature: 0.3
max_tokens: 500
```

**Output:**

```
success: true
data:
  overall_price: {coins: 45, credits: 0.045}
  completions:
    gpt-4-vision:
      completion: "This image shows a modern smartphone..."
    claude-3-opus:
      completion: "The photograph displays a sleek mobile device..."
    gemini-pro-vision:
      completion: "I can see a contemporary smartphone model..."
```

### Example 3: Document Analysis with YouTube Transcript

**Input:**

```
models: ["gpt-4", "claude-3-sonnet"]
message: "Summarize the key points from this video and create a 5-item action checklist"
youtube_urls: ["https://youtube.com/watch?v=example123"]
display_transcripts: true
temperature: 0.2
max_tokens: 1000
```

**Output:**

```
success: true
data:
  transcripts: [
    {name: "example123", text: "Welcome to this tutorial..."}
  ]
  completions:
    gpt-4:
      completion: "Key Points:\n1. Introduction to AI workflows..."
    claude-3-sonnet:
      completion: "Main Takeaways:\n1. Automation fundamentals..."
```

## Common Use Cases

* **Model Comparison**: Test multiple AI models simultaneously to compare quality, tone, and accuracy of responses for your specific use case
* **Content Generation**: Generate marketing copy, blog posts, or product descriptions using multiple models to select the best output
* **Multi-Modal Analysis**: Analyze images, documents, and videos with AI models that support vision and document understanding
* **Research & Summarization**: Process YouTube videos, PDFs, and documents to extract key insights and summaries
* **Cost Optimization**: Compare pricing across different models to find the most cost-effective solution for your workload
* **Quality Assurance**: Use multiple models to cross-validate AI-generated content and improve accuracy
* **Brainstorming**: Generate diverse creative ideas by leveraging different AI models with varying capabilities and perspectives

## Error Handling

| Error Type            | Cause                                               | Solution                                                                           |
| --------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------- |
| Invalid Model         | Model identifier doesn't exist in Straico's catalog | Check Straico documentation for valid model names and ensure spelling is correct   |
| Authentication Failed | Invalid or missing Straico API credentials          | Verify your Straico connection is properly configured with valid API key           |
| Too Many Models       | More than 4 models specified in the request         | Reduce the number of models to 4 or fewer per request                              |
| Rate Limit Exceeded   | Too many requests sent in short time period         | Implement delays between requests or upgrade your Straico plan                     |
| Invalid File URL      | File URL not accessible or not previously uploaded  | Upload files through Straico's File Upload endpoint first and use the returned URL |
| Token Limit Exceeded  | max\_tokens exceeds model's maximum context window  | Reduce max\_tokens value or use a model with larger context window                 |
| Invalid Temperature   | Temperature value outside 0-2 range                 | Set temperature between 0 (deterministic) and 2 (very creative)                    |

## Notes

* **Multi-Model Access**: Straico provides unified access to multiple AI providers (OpenAI, Anthropic, Google, etc.) through a single API, simplifying model comparison
* **Cost Tracking**: The response includes detailed pricing information in both coins and credits for accurate cost monitoring
* **Temperature Control**: Lower temperature (0-0.3) for factual responses, medium (0.4-0.7) for balanced output, higher (0.8-2.0) for creative content
* **Image Support**: Up to 4 images can be included with your prompt for vision-capable models to analyze
* **File Processing**: Upload documents via Straico's File Upload endpoint first, then reference them by URL in your prompt
* **YouTube Integration**: Provide YouTube URLs to have Straico automatically extract and process video transcripts
* **Word Count Metrics**: Track input, output, and total word counts for each model to monitor usage and optimize costs
* **Batch Efficiency**: Comparing multiple models in a single request is more efficient than making separate API calls for each model


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/straico_prompt_completion.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
