Authentication with API Keys
To ensure secure access to our platform, Lamatic.ai employs API keys for authentication. When triggering flows via GraphQL, you'll need to include your API key in the request headers. This key serves as a unique identifier, granting you authorized access to our services while maintaining the integrity and confidentiality of your data.
How to Get the API Key
- Navigate to Studio > Settings
- Select API Keys, and click the Create a New API Key button.
Here's an example of how you can include the API key in your GraphQL request headers:
Authorization: Bearer your_api_key
By including the API key in the Authorization
header, our platform can verify your identity and grant you access to trigger the desired flow.
After recreating the API key, the project must be redeployed.
Triggering Flows with GraphQL
Lamatic.ai's GraphQL integration allows you to trigger your GenAI flows seamlessly using GraphQL queries. This approach provides a standardized and efficient way to interact with our platform, enabling you to execute your GenAI flows on-demand or as part of larger application flows.
Here's an example GraphQL query that demonstrates how you can trigger a flow:
const axios = require('axios');
const query = `
query ExecuteWorkflow(
$workflowId: String!
$prompt: String
) {
executeWorkflow(
workflowId: $workflowId
payload: {
prompt: $prompt
}
) {
status
result
}
}`;
const variables = {"workflowId":"your_workflow_id","prompt":"The excited car draws."};
const options = {
method: 'POST',
url: 'your_project_endpoint',
headers: {
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
},
data: { query, variables }
};
axios(options)
.then(response => console.log(response.data))
.catch(error => console.error(error));
Output
The Structure output can be configured in the Schema of the Graphql Response node. The expected output will be as follows:
{
// Expected Output as setuped in the Schema
}
In this example, the ExecuteWorkflow
query is used to initiate a workflow execution. You'll need to provide the workflowId
of the desired workflow and any required payload
(Input Data) as part of the query variables.