You have to pass two parameters to the request body: inputs and version.InputsPass the inputs for this WordApp as a JSON object. The keys are the names of the inputs defined in the WordApp,
and the values are the actual values you want to use for those inputs.
For audio and image inputs you need to specify the type and provide a publicly accessible URL.
VersionWe use a simplified semantic versioning. All versions follow the format <major>.<minor>, for example 1.0.You have to pass the version number you want to use. You can use the caret syntax like this to get the latest minor version: ^1.0. We recommend you use this syntax when you build your APIs. Example:
It is super easy to stream the response from the API. We’ll send you chunks of the response as they’re generated. Below
you can find examples of how to consume the response in Python and JavaScript.
import jsonimport requestsdef main(): app_id = "YOUR_APP_ID" api_key = "YOUR_API_KEY" # Execute the prompt r = requests.post(f"https://app.wordware.ai/api/released-app/{app_id}/run", json={ "inputs": { "topic": "sugary cereal", # Image inputs have a different format and require a publicly accessible URL "image": { "type": "image", "image_url": "https://i.insider.com/602ee9ced3ad27001837f2ac", }, "version": "^1.0" } }, headers={"Authorization": f"Bearer {api_key}"}, stream=True ) # Ensure the request was successful if r.status_code != 200: print("Request failed with status code", r.status_code) print(json.dumps(r.json(), indent=4)) else: for line in r.iter_lines(): if line: content = json.loads(line.decode('utf-8')) value = content['value'] # We can print values as they're generated if value['type'] == 'generation': if value['state'] == "start": print("\nNEW GENERATION -", value['label']) else: print("\nEND GENERATION -", value['label']) elif value['type'] == "chunk": print(value['value'], end="") elif value['type'] == "outputs": # Or we can read from the outputs at the end # Currently we include everything by ID and by label - this will likely change in future in a breaking # change but with ample warning print("\nFINAL OUTPUTS:") print(json.dumps(value, indent=4))if __name__ == '__main__': main()