# Request Logs

Request logs are a powerful tool to understand your data. Even better, you can import recorded logs directly into your training datasets, making it simple to train on real-world data collected in production.

\
We recommend gathering request logs for both base and fine-tuned models. Fryday provides several flexible options for recording your requests.

### Proxy

Fryday offers a /chat/completions endpoint that is fully compatible with OpenAI, allowing you to use features like tool calls seamlessly.

Integrating the Proxy and Logging Requests Here’s how to get started:

1. Add an OpenAI key to your project in the [project settings](https://fryday.ai/app/settings) page.
2. Set the authorization token in your request to be your Fryday API key.
3. Set the destination URL of your request to be `https://api.fryday.ai/v1/chat/completions` or if you're using the OpenAI SDK, set the base URL as `https://api.fryday.ai/v1`
4. (Optional) **Add a Prompt ID**: Include the prompt ID using the **X-Prompt-ID** header to help track and identify specific prompts. Check the example on how to do this.

### Example

{% tabs %}
{% tab title="JavaScript" %}

```javascript
import OpenAI from "openai";

// Initialize OpenAI client with API key
const openai = new OpenAI({
    apiKey: process.env.FRYDAY_API_KEY, // Replace with your actual API key
    baseURL: "https://api.fryday.ai/v1", // Fryday's base URL
});

async function createChatCompletion() {
    try {
        const chatCompletion = await openai.chat.completions.create({
            messages: [
                { role: "system", content: "You are an assistant that helps users answer simple questions." },
                { role: "user", content: "What is the capital of France?" }
            ],
            model: "gpt-4o-mini",  // Replace with your model name
            headers: {
                "X-Prompt-ID": "your_prompt_id_here"
            },
        });

        console.log(chatCompletion);
    } catch (error) {
        console.error("Error creating chat completion:", error);
    }
}

createChatCompletion();
```

{% endtab %}

{% tab title="Python" %}

```python
from openai import OpenAI

# Initialize client with base URL and API key
client = OpenAI(
    base_url="https://api.fryday.ai/v1",
    api_key="your_project_api_key_here",
)

# Create a chat completion
chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "system",
            "content": "You are an assistant that helps users choose between options."
        },
        {
            "role": "user",
            "content": "What is the correct option for this task?"
        }
    ],
    model="gpt-4o",  # Replace with your model name
    extra_headers={"X-Prompt-ID": "your_prompt_id_here"},
)

print(chat_completion)
```

{% endtab %}
{% endtabs %}

Let me know if this works for you!


---

# 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.fryday.ai/features/request-logs.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.
