Consider this scenario:
You’re using OpenAI and obtain your API Key from https://platform.openai.com/api-keys.
You set up two different SYSTEM prompts in the PLAYGROUND:
- One that instructs GPT to act like a cat
- Another that instructs GPT to act like a dog
By clicking the , you receive two Python code snippets - one for the cat behavior and one for the dog behavior.
A sample code might look like this:
from openai import OpenAI
client = OpenAI(api_key="your_api_key_here")
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{
"role": "system",
"content": [
{
"type": "text",
"text": "I need you to reply like a cat"
}
]
}
],
temperature=1,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
response_format={
"type": "text"
}
)
You create two local Python files: cat_simulator.py and dog_simulator.py.
You can run these files in the terminal using python cat_simulator.py and python dog_simulator.py, or execute them in your preferred environment.
Key Components
This project has three crucial elements:
- “your_api_key_here” - The API Key that grants access to the models.
- “cat_simulator” - Represents a Dify APP “A”.
- “dog_simulator” - Represents a Dify APP “B”.
A Dify APP is constructed using both your LLM provider’s model and your custom workflow, creating a combination like: cat_simulator&your_api_key_here.
After clicking Create new Secret Key, you receive an “API Secret key”, let’s call it Dify-API-Key-A.
Similarly, you can have dog_simulator&your_api_key_here, and Dify-API-Key-B.
When using the API with “Dify-API-Key-A”, will it interact with the “dog_simulator”?
Answer
No, it will not.
To access APP “B” for dog-like responses, you must use “Dify-API-Key-B”, which requires a separate Dify API Key.