Response via Inference API does not meet the expectation

Hi. I have written a simple python application with streamlit to rewrite content via the inference api. The problem is that the content is not rewritten, but extended. I have already tried this with different models, the result is always the same. However, the application itself works correctly when I use it with the OpenAi API. So it seems to be purely due to the models.

import os
import requests
import streamlit as st

#API_URL = "https://api-inference.huggingface.co/models/mistralai/Mixtral-8x7B-Instruct-v0.1"
API_URL = "https://api-inference.huggingface.co/models/HuggingFaceH4/zephyr-7b-beta"
API_TOKEN = os.environ.get("HF_API_TOKEN")

headers = {"Authorization": f"Bearer {API_TOKEN}"}

def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    if response.status_code != 200:
        raise Exception(f"API request failed with status code {response.status_code}: {response.text}")
    return response.json()

def main():
    st.title("Mixtral-8x7B-Instruct-v0.1 Model Demo")
    input_text = st.text_area("Enter your input text:", height=200)
    # Define your prompt text here
    prompt_text = "Rewrite the following text: "
    if st.button("Generate Output"):
        if input_text:
            with st.spinner("Processing..."):
                try:
                    # Prepend the prompt text to the input text
                    combined_input = prompt_text + input_text
                    output = query({"inputs": combined_input})
                    # Check if output is structured as expected
                    if not isinstance(output, list) or "generated_text" not in output[0]:
                        st.error("Unexpected response format.")
                        st.json(output)  # Show the full output for debugging
                    else:
                        output_text = output[0]["generated_text"]
                        st.text_area("Output:", value=output_text, height=300)
                except Exception as e:
                    st.error(f"An error occurred: {e}")
        else:
            st.warning("Please enter some text.")

if __name__ == "__main__":
    main()