# HTTP Requests

Use the API without an SDK - just plain HTTP requests.

## Non-Streaming Request

For simple requests without streaming (note the `-X POST` method):

```bash
curl -X POST https://api-bizora.ai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -d '{
    "model": "bizora-1.0",
    "messages": [
      {"role": "human", "content": "What is section 179?"}
    ]
  }'
```

## Streaming Request (Recommended)

For real-time streaming, use `-X POST` method, add the `-N` flag and set `stream: true`:

```bash
curl -X POST -N https://api-bizora.ai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -d '{
    "model": "bizora-1.0",
    "messages": [
      {"role": "human", "content": "What is section 179?"}
    ],
    "stream": true
  }'
```

## Using HTTP Libraries (Non-Streaming)

If you prefer using HTTP libraries directly instead of the OpenAI SDK:

```python
import requests

url = "https://api-bizora.ai/chat/completions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk_live_YOUR_API_KEY"
}
data = {
    "model": "bizora-1.0",
    "messages": [{"role": "human", "content": "What is section 179?"}]
}

response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result['choices'][0]['message']['content'])
```

```javascript
const response = await fetch('https://api-bizora.ai/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer sk_live_YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: 'bizora-1.0',
    messages: [{ role: 'human', content: 'What is section 179?' }]
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);
```

## Zero Data Retention Opt-In

Zero data retention is disabled by default. To enable it for a specific HTTP request, include `"ZeroDataRetention": true` in the JSON body.

When enabled, prompt and response content is not retained for that request. Some models or providers may be unavailable because they do not support zero data retention. You should handle abuse monitoring for zero data retention traffic because Bizora has limited content visibility for those requests.

```bash
curl -X POST https://api-bizora.ai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -d '{
    "model": "bizora-1.0",
    "messages": [
      {"role": "human", "content": "What is section 179?"}
    ],
    "ZeroDataRetention": true
  }'
```

## Streaming with HTTP Libraries (Recommended)

For real-time streaming with raw HTTP libraries:

```python
import requests
import json

# Make streaming request
response = requests.post(
    "https://api-bizora.ai/chat/completions",
    headers={
        "Authorization": "Bearer sk_live_YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "model": "bizora-1.0",
        "messages": [{"role": "human", "content": "What is section 179?"}],
        "stream": True
    },
    stream=True
)

# Process SSE stream
for line in response.iter_lines():
    if line:
        line = line.decode('utf-8')
        if line.startswith('data: '):
            data = line[6:]
            if data == '[DONE]':
                break
            chunk = json.loads(data)
            content = chunk['choices'][0].get('delta', {}).get('content')
            if content:
                print(content, end='', flush=True)
```

```javascript
// Make streaming request
const response = await fetch('https://api-bizora.ai/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer sk_live_YOUR_API_KEY'
  },
  body: JSON.stringify({
    model: 'bizora-1.0',
    messages: [{ role: 'human', content: 'What is section 179?' }],
    stream: true
  })
});

// Process SSE stream
const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  
  const chunk = decoder.decode(value);
  const lines = chunk.split('\n');
  
  for (const line of lines) {
    if (line.startsWith('data: ')) {
      const data = line.slice(6);
      if (data === '[DONE]') break;
      
      const parsed = JSON.parse(data);
      const content = parsed.choices?.[0]?.delta?.content;
      if (content) {
        process.stdout.write(content);
      }
    }
  }
}
```
