helicone-rb 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2be72b17bc38b9d451b2888a29407c7af83212d26c580ec22de03cdb9a97c0fb
4
- data.tar.gz: 17682bc18311ebc1c2be4e3607db90b3e9d7c2fc90bfeedae38e8bef67e79321
3
+ metadata.gz: 7e47a2406f0ff4091abc0a4720eaa015bd157b76dc8c231c1d9b3e6fe2ed97c4
4
+ data.tar.gz: 6c9debdd6b54fead261c3ba10b7cee76aa25b4e0ea15c1b3324b1e8d56713ff7
5
5
  SHA512:
6
- metadata.gz: 5641f51284e72fdcc5a74f68b38fb9afe0cd11607dda855e6193ec555c6c8aae5d2507b4ce0a7e39161ec5a6fd2e22d0a0d19200e895641167a93cffd50914ef
7
- data.tar.gz: 5ea90b79077f3ffc5b19c98ae8ab998790bd8580bb63ecf70fc7f3ee74d9e447f61a4d518007bcc2c17a988adcda0df26cfa0f6e1ae110838b2037f8dab3ff80
6
+ metadata.gz: d06ffd02119a05aa69abffd784e545f00c914554e2ccf36c7dce952aa24417055ba6ea4d10c17d6979d736b754f19d6bdfbad04044d02f91ddc6ce4df1c95960
7
+ data.tar.gz: 20f39820ca78bd10e6ff7205b42cd78f24865632281da0c07456b2c5af5ff90f49ab79f1e48984cbffa5cffc6c1c455ed424ab5c5c47a84486d5758193730a10
data/README.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  A Ruby client for the [Helicone AI Gateway](https://helicone.ai), wrapping the OpenAI API with built-in session tracking, cost attribution, and an agentic framework for building AI applications with tool/function calling.
4
4
 
5
+ ## Why Helicone?
6
+
7
+ [Helicone](https://helicone.ai) is an AI gateway that sits between your application and LLM providers (OpenAI, Anthropic, etc.). It provides:
8
+
9
+ - **Unified billing** - One API key, one bill, access to multiple providers
10
+ - **Request logging** - Every API call is logged with full request/response details
11
+ - **Cost tracking** - See exactly what you're spending per user, session, or feature
12
+ - **Latency monitoring** - Track response times and identify slow requests
13
+ - **Rate limiting & caching** - Built-in protection and optimization
14
+
15
+ ![Helicone Dashboard](readme-assets/helicone-dashboard.png)
16
+
17
+ *The Helicone dashboard shows all your LLM requests with latency, cost, and token usage at a glance.*
18
+
5
19
  ## Installation
6
20
 
7
21
  Add this line to your application's Gemfile:
@@ -24,14 +38,30 @@ gem install helicone-rb
24
38
 
25
39
  ## Configuration
26
40
 
27
- Configure the gem with your API key and optional settings:
41
+ First, [sign up for a Helicone account](https://us.helicone.ai/signup) to get your API key.
42
+
43
+ Set the `HELICONE_API_KEY` environment variable:
44
+
45
+ ```bash
46
+ export HELICONE_API_KEY=sk-helicone-your-key-here
47
+ ```
48
+
49
+ That's it! The gem reads from `ENV["HELICONE_API_KEY"]` automatically.
50
+
51
+ Helicone handles billing and routes requests to OpenAI or other providers. See the [model registry](https://www.helicone.ai/models) for supported models including GPT-4, Claude, Llama, and more.
52
+
53
+ ![Helicone Model Registry](readme-assets/helicone-model-registry.png)
54
+
55
+ *Browse all available models with pricing, context windows, and capabilities in the Helicone model registry.*
56
+
57
+ ### Optional Configuration
58
+
59
+ You can optionally configure the default model and logger:
28
60
 
29
61
  ```ruby
30
62
  Helicone.configure do |config|
31
- config.api_key = ENV['OPENAI_API_KEY']
32
- config.uri_base = "https://oai.helicone.ai/v1" # default
33
- config.default_model = "gpt-4" # default
34
- config.logger = Logger.new($stdout) # default
63
+ config.default_model = "gpt-4o" # default
64
+ config.logger = Logger.new($stdout) # default
35
65
  end
36
66
  ```
37
67
 
@@ -98,7 +128,7 @@ response = client.chat(messages: [message])
98
128
 
99
129
  ## Session and Account Tracking
100
130
 
101
- Track conversations and costs in the Helicone dashboard:
131
+ Track conversations and attribute costs to specific users or accounts in the Helicone dashboard:
102
132
 
103
133
  ```ruby
104
134
  client = Helicone::Client.new(
@@ -109,6 +139,12 @@ client = Helicone::Client.new(
109
139
  )
110
140
  ```
111
141
 
142
+ Sessions group related requests together, letting you see the full flow of a conversation or agentic workflow:
143
+
144
+ ![Helicone Session Flamegraph](readme-assets/helicone-session-flamegraph.png)
145
+
146
+ *The session view shows each request in a conversation as a flamegraph, with timing and token usage for each step. Great for debugging agent loops and understanding where time and tokens are spent.*
147
+
112
148
  ## Agentic Framework
113
149
 
114
150
  Build AI agents that can use tools to accomplish tasks.
@@ -254,6 +290,14 @@ bundle install
254
290
  bundle exec rspec
255
291
  ```
256
292
 
293
+ ### Live Integration Tests
294
+
295
+ To run tests against the actual Helicone API:
296
+
297
+ ```bash
298
+ HELICONE_LIVE_TEST=true HELICONE_API_KEY=your_key bundle exec rspec spec/helicone/integration_spec.rb
299
+ ```
300
+
257
301
  ## Contributing
258
302
 
259
303
  Bug reports and pull requests are welcome on GitHub at https://github.com/genevere-inc/helicone-rb.
@@ -6,17 +6,14 @@ module Helicone
6
6
 
7
7
  # Initialize with optional session/account context for Helicone tracking
8
8
  #
9
- # @param api_key [String] OpenAI API key (defaults to Helicone.configuration.api_key)
10
9
  # @param session_id [String, Integer] Conversation/session ID for Helicone grouping
11
10
  # @param session_name [String] Human-readable session name
12
11
  # @param account_id [String, Integer] Account ID for cost tracking per account
13
12
  # @param account_name [String] Human-readable account name
14
- def initialize(api_key: nil, session_id: nil, session_name: nil, account_id: nil, account_name: nil)
15
- config = Helicone.configuration
16
-
13
+ def initialize(session_id: nil, session_name: nil, account_id: nil, account_name: nil)
17
14
  @client = OpenAI::Client.new(
18
- access_token: api_key || config.api_key,
19
- uri_base: config.uri_base
15
+ access_token: ENV["HELICONE_API_KEY"],
16
+ uri_base: Helicone::URI_BASE
20
17
  )
21
18
 
22
19
  # Add Helicone session headers if provided
@@ -3,15 +3,16 @@
3
3
  require "logger"
4
4
 
5
5
  module Helicone
6
+ URI_BASE = "https://ai-gateway.helicone.ai/v1"
7
+
6
8
  class Configuration
7
- attr_accessor :api_key, :uri_base, :logger, :default_model
9
+ attr_accessor :logger, :default_model
8
10
 
9
11
  # Initialize configuration with defaults
10
12
  #
11
13
  # @return [Configuration]
12
14
  def initialize
13
- @uri_base = "https://oai.helicone.ai/v1"
14
- @default_model = "gpt-4"
15
+ @default_model = "gpt-4o"
15
16
  @logger = Logger.new($stdout, level: Logger::INFO)
16
17
  end
17
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helicone
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helicone-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genevere
@@ -90,6 +90,9 @@ files:
90
90
  - lib/helicone/tool.rb
91
91
  - lib/helicone/tool_call.rb
92
92
  - lib/helicone/version.rb
93
+ - readme-assets/helicone-dashboard.png
94
+ - readme-assets/helicone-model-registry.png
95
+ - readme-assets/helicone-session-flamegraph.png
93
96
  homepage: https://github.com/genevere-inc/helicone-rb
94
97
  licenses:
95
98
  - MIT